From: Mateusz Guzik <mjguzik@gmail.com>
To: viro@zeniv.linux.org.uk
Cc: brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, Mateusz Guzik <mjguzik@gmail.com>
Subject: [PATCH v2] fs: hide names_cache behind runtime const machinery
Date: Mon, 1 Dec 2025 09:32:26 +0100 [thread overview]
Message-ID: <20251201083226.268846-1-mjguzik@gmail.com> (raw)
s/names_cachep/names_cache/ for consistency with dentry cache.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
v2:
- rebased on top of work.filename-refcnt
ACHTUNG: there is a change queued for 6.19 merge window which treats
dentry cache the same way:
commit 21b561dab1406e63740ebe240c7b69f19e1bcf58
Author: Mateusz Guzik <mjguzik@gmail.com>
Date: Wed Nov 5 16:36:22 2025 +0100
fs: hide dentry_cache behind runtime const machinery
which would result in a merge conflict in vmlinux.lds.h. thus I
cherry-picked before generating the diff to avoid the issue for later.
fs/namei.c | 16 ++++++++++------
include/asm-generic/vmlinux.lds.h | 3 ++-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index d6eac90084e1..eff4cbffe241 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -41,6 +41,8 @@
#include <linux/init_task.h>
#include <linux/uaccess.h>
+#include <asm/runtime-const.h>
+
#include "internal.h"
#include "mount.h"
@@ -124,23 +126,25 @@
*/
/* SLAB cache for struct filename instances */
-static struct kmem_cache *names_cachep __ro_after_init;
+static struct kmem_cache *__names_cache __ro_after_init;
+#define names_cache runtime_const_ptr(__names_cache)
void __init filename_init(void)
{
- names_cachep = kmem_cache_create_usercopy("names_cache", sizeof(struct filename), 0,
- SLAB_HWCACHE_ALIGN|SLAB_PANIC, offsetof(struct filename, iname),
- EMBEDDED_NAME_MAX, NULL);
+ __names_cache = kmem_cache_create_usercopy("names_cache", sizeof(struct filename), 0,
+ SLAB_HWCACHE_ALIGN|SLAB_PANIC, offsetof(struct filename, iname),
+ EMBEDDED_NAME_MAX, NULL);
+ runtime_const_init(ptr, __names_cache);
}
static inline struct filename *alloc_filename(void)
{
- return kmem_cache_alloc(names_cachep, GFP_KERNEL);
+ return kmem_cache_alloc(names_cache, GFP_KERNEL);
}
static inline void free_filename(struct filename *p)
{
- kmem_cache_free(names_cachep, p);
+ kmem_cache_free(names_cache, p);
}
static inline void initname(struct filename *name)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 20939d2445e7..3abd76ac723a 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -956,7 +956,8 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
#define RUNTIME_CONST_VARIABLES \
RUNTIME_CONST(shift, d_hash_shift) \
RUNTIME_CONST(ptr, dentry_hashtable) \
- RUNTIME_CONST(ptr, __dentry_cache)
+ RUNTIME_CONST(ptr, __dentry_cache) \
+ RUNTIME_CONST(ptr, __names_cache)
/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
#define KUNIT_TABLE() \
--
2.48.1
next reply other threads:[~2025-12-01 8:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 8:32 Mateusz Guzik [this message]
2025-12-01 8:51 ` [PATCH v2] fs: hide names_cache behind runtime const machinery Al Viro
2025-12-02 2:31 ` Al Viro
2025-12-02 5:10 ` Mateusz Guzik
2025-12-02 5:52 ` Al Viro
2025-12-02 6:18 ` Mateusz Guzik
2025-12-02 6:32 ` Al Viro
2025-12-02 7:21 ` Al Viro
2025-12-02 6:20 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251201083226.268846-1-mjguzik@gmail.com \
--to=mjguzik@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).