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

codetag: avoid unused alloc_tags sections/symbols

With CONFIG_MEM_ALLOC_PROFILING=n, vmlinux and all modules unnecessarily
contain the symbols __start_alloc_tags and __stop_alloc_tags, which define
an empty range. In the case of modules, the presence of these symbols
also forces the linker to create an empty .codetag.alloc_tags section.

Update codetag.lds.h to make the data conditional on
CONFIG_MEM_ALLOC_PROFILING.

Link: https://lkml.kernel.org/r/20250618125037.53182-1-petr.pavlu@suse.com
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Reviewed-by: Kent Overstreet <kent.overstreet@linux.dev>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Casey Chen <cachen@purestorage.com>
Cc: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Petr Pavlu and committed by
Andrew Morton
d29d64af f9550e1f

+8 -2
+8 -2
include/asm-generic/codetag.lds.h
··· 2 2 #ifndef __ASM_GENERIC_CODETAG_LDS_H 3 3 #define __ASM_GENERIC_CODETAG_LDS_H 4 4 5 + #ifdef CONFIG_MEM_ALLOC_PROFILING 6 + #define IF_MEM_ALLOC_PROFILING(...) __VA_ARGS__ 7 + #else 8 + #define IF_MEM_ALLOC_PROFILING(...) 9 + #endif 10 + 5 11 #define SECTION_WITH_BOUNDARIES(_name) \ 6 12 . = ALIGN(8); \ 7 13 __start_##_name = .; \ ··· 15 9 __stop_##_name = .; 16 10 17 11 #define CODETAG_SECTIONS() \ 18 - SECTION_WITH_BOUNDARIES(alloc_tags) 12 + IF_MEM_ALLOC_PROFILING(SECTION_WITH_BOUNDARIES(alloc_tags)) 19 13 20 14 #define MOD_SEPARATE_CODETAG_SECTION(_name) \ 21 15 .codetag.##_name : { \ ··· 28 22 * unload them individually once unused. 29 23 */ 30 24 #define MOD_SEPARATE_CODETAG_SECTIONS() \ 31 - MOD_SEPARATE_CODETAG_SECTION(alloc_tags) 25 + IF_MEM_ALLOC_PROFILING(MOD_SEPARATE_CODETAG_SECTION(alloc_tags)) 32 26 33 27 #endif /* __ASM_GENERIC_CODETAG_LDS_H */