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.

lib/alloc_tag: do not register sysctl interface when CONFIG_SYSCTL=n

Memory allocation profiling is trying to register sysctl interface even
when CONFIG_SYSCTL=n, resulting in proc_do_static_key() being undefined.
Prevent that by skipping sysctl registration for such configurations.

Link: https://lkml.kernel.org/r/20240601233831.617124-1-surenb@google.com
Fixes: 22d407b164ff ("lib: add allocation tagging support for memory allocation profiling")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202405280616.wcOGWJEj-lkp@intel.com/
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Kees Cook <keescook@chromium.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Suren Baghdasaryan and committed by
Andrew Morton
c944bf60 3ab85f40

+13 -3
+13 -3
lib/alloc_tag.c
··· 227 227 }; 228 228 EXPORT_SYMBOL(page_alloc_tagging_ops); 229 229 230 + #ifdef CONFIG_SYSCTL 230 231 static struct ctl_table memory_allocation_profiling_sysctls[] = { 231 232 { 232 233 .procname = "mem_profiling", ··· 242 241 { } 243 242 }; 244 243 244 + static void __init sysctl_init(void) 245 + { 246 + if (!mem_profiling_support) 247 + memory_allocation_profiling_sysctls[0].mode = 0444; 248 + 249 + register_sysctl_init("vm", memory_allocation_profiling_sysctls); 250 + } 251 + #else /* CONFIG_SYSCTL */ 252 + static inline void sysctl_init(void) {} 253 + #endif /* CONFIG_SYSCTL */ 254 + 245 255 static int __init alloc_tag_init(void) 246 256 { 247 257 const struct codetag_type_desc desc = { ··· 265 253 if (IS_ERR(alloc_tag_cttype)) 266 254 return PTR_ERR(alloc_tag_cttype); 267 255 268 - if (!mem_profiling_support) 269 - memory_allocation_profiling_sysctls[0].mode = 0444; 270 - register_sysctl_init("vm", memory_allocation_profiling_sysctls); 256 + sysctl_init(); 271 257 procfs_init(); 272 258 273 259 return 0;