Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

runtime constants: add default dummy infrastructure

This adds the initial dummy support for 'runtime constants' for when
an architecture doesn't actually support an implementation of fixing
up said runtime constants.

This ends up being the fallback to just using the variables as regular
__ro_after_init variables, and changes the dcache d_hash() function to
use this model.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+34 -1
+10 -1
fs/dcache.c
··· 35 35 #include "internal.h" 36 36 #include "mount.h" 37 37 38 + #include <asm/runtime-const.h> 39 + 38 40 /* 39 41 * Usage: 40 42 * dcache->d_inode->i_lock protects: ··· 104 102 105 103 static inline struct hlist_bl_head *d_hash(unsigned long hashlen) 106 104 { 107 - return dentry_hashtable + ((u32)hashlen >> d_hash_shift); 105 + return runtime_const_ptr(dentry_hashtable) + 106 + runtime_const_shift_right_32(hashlen, d_hash_shift); 108 107 } 109 108 110 109 #define IN_LOOKUP_SHIFT 10 ··· 3132 3129 0, 3133 3130 0); 3134 3131 d_hash_shift = 32 - d_hash_shift; 3132 + 3133 + runtime_const_init(shift, d_hash_shift); 3134 + runtime_const_init(ptr, dentry_hashtable); 3135 3135 } 3136 3136 3137 3137 static void __init dcache_init(void) ··· 3163 3157 0, 3164 3158 0); 3165 3159 d_hash_shift = 32 - d_hash_shift; 3160 + 3161 + runtime_const_init(shift, d_hash_shift); 3162 + runtime_const_init(ptr, dentry_hashtable); 3166 3163 } 3167 3164 3168 3165 /* SLAB cache for __getname() consumers */
+1
include/asm-generic/Kbuild
··· 46 46 mandatory-y += percpu.h 47 47 mandatory-y += pgalloc.h 48 48 mandatory-y += preempt.h 49 + mandatory-y += runtime-const.h 49 50 mandatory-y += rwonce.h 50 51 mandatory-y += sections.h 51 52 mandatory-y += serial.h
+15
include/asm-generic/runtime-const.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _ASM_RUNTIME_CONST_H 3 + #define _ASM_RUNTIME_CONST_H 4 + 5 + /* 6 + * This is the fallback for when the architecture doesn't 7 + * support the runtime const operations. 8 + * 9 + * We just use the actual symbols as-is. 10 + */ 11 + #define runtime_const_ptr(sym) (sym) 12 + #define runtime_const_shift_right_32(val, sym) ((u32)(val)>>(sym)) 13 + #define runtime_const_init(type,sym) do { } while (0) 14 + 15 + #endif
+8
include/asm-generic/vmlinux.lds.h
··· 944 944 #define CON_INITCALL \ 945 945 BOUNDED_SECTION_POST_LABEL(.con_initcall.init, __con_initcall, _start, _end) 946 946 947 + #define RUNTIME_NAME(t,x) runtime_##t##_##x 948 + 949 + #define RUNTIME_CONST(t,x) \ 950 + . = ALIGN(8); \ 951 + RUNTIME_NAME(t,x) : AT(ADDR(RUNTIME_NAME(t,x)) - LOAD_OFFSET) { \ 952 + *(RUNTIME_NAME(t,x)); \ 953 + } 954 + 947 955 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */ 948 956 #define KUNIT_TABLE() \ 949 957 . = ALIGN(8); \