]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs: hide dentry_cache behind runtime const machinery
authorMateusz Guzik <mjguzik@gmail.com>
Wed, 5 Nov 2025 15:36:22 +0000 (16:36 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 12 Nov 2025 11:19:09 +0000 (12:19 +0100)
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://patch.msgid.link/20251105153622.758836-1-mjguzik@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/dcache.c
include/asm-generic/vmlinux.lds.h

index 035cccbc927658abf16850a6174ed3661998ee52..5c6282b03ba26c8d049734fcd029f55b774f4da8 100644 (file)
@@ -86,7 +86,8 @@ __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
 
 EXPORT_SYMBOL(rename_lock);
 
-static struct kmem_cache *dentry_cache __ro_after_init;
+static struct kmem_cache *__dentry_cache __ro_after_init;
+#define dentry_cache runtime_const_ptr(__dentry_cache)
 
 const struct qstr empty_name = QSTR_INIT("", 0);
 EXPORT_SYMBOL(empty_name);
@@ -3222,9 +3223,10 @@ static void __init dcache_init(void)
         * but it is probably not worth it because of the cache nature
         * of the dcache.
         */
-       dentry_cache = KMEM_CACHE_USERCOPY(dentry,
+       __dentry_cache = KMEM_CACHE_USERCOPY(dentry,
                SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_ACCOUNT,
                d_shortname.string);
+       runtime_const_init(ptr, __dentry_cache);
 
        /* Hash may have been set up in dcache_init_early */
        if (!hashdist)
index 8a9a2e732a65b04d18453e266900895ef41bb615..20939d2445e7877f58823abbfb0db54c164f0a86 100644 (file)
@@ -955,7 +955,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_hashtable)                    \
+               RUNTIME_CONST(ptr, __dentry_cache)
 
 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
 #define KUNIT_TABLE()                                                  \