mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [WIP RFC PATCH] fs: hide names_cachep behind runtime_const machinery
@ 2025-10-29 13:55 Mateusz Guzik
  2025-10-29 15:08 ` Mateusz Guzik
  0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Guzik @ 2025-10-29 13:55 UTC (permalink / raw)
  To: brauner; +Cc: viro, jack, linux-kernel, linux-fsdevel, Mateusz Guzik

All path lookups end up allocating and freeing a buffer. The namei cache
is created and at boot time and remains constant, meaning there is no
reason to spend a cacheline to load the pointer.

I verified this boots on x86-64.

The problem is that when building I get the following:
ld: warning: orphan section `runtime_ptr_names_cachep' from `vmlinux.o' being placed in section `runtime_ptr_names_cachep'

I don't know what's up with that yet, but I will sort it out. Before I
put any effort into it I need to know if the idea looks fine.

---
 fs/dcache.c        | 1 +
 include/linux/fs.h | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 035cccbc9276..786d09798313 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3265,6 +3265,7 @@ void __init vfs_caches_init(void)
 {
 	names_cachep = kmem_cache_create_usercopy("names_cache", PATH_MAX, 0,
 			SLAB_HWCACHE_ALIGN|SLAB_PANIC, 0, PATH_MAX, NULL);
+	runtime_const_init(ptr, names_cachep);
 
 	dcache_init();
 	inode_init();
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 68c4a59ec8fb..08ea27340309 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2960,8 +2960,9 @@ extern void __init vfs_caches_init(void);
 
 extern struct kmem_cache *names_cachep;
 
-#define __getname()		kmem_cache_alloc(names_cachep, GFP_KERNEL)
-#define __putname(name)		kmem_cache_free(names_cachep, (void *)(name))
+#define __const_names_cachep	runtime_const_ptr(names_cachep)
+#define __getname()		kmem_cache_alloc(__const_names_cachep, GFP_KERNEL)
+#define __putname(name)		kmem_cache_free(__const_names_cachep, (void *)(name))
 
 extern struct super_block *blockdev_superblock;
 static inline bool sb_is_blkdev_sb(struct super_block *sb)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-29 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-29 13:55 [WIP RFC PATCH] fs: hide names_cachep behind runtime_const machinery Mateusz Guzik
2025-10-29 15:08 ` Mateusz Guzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®