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>
pull/1311/head
Petr Pavlu 2025-06-18 14:50:35 +02:00 committed by Andrew Morton
parent f9550e1fcf
commit d29d64afa2
1 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,12 @@
#ifndef __ASM_GENERIC_CODETAG_LDS_H #ifndef __ASM_GENERIC_CODETAG_LDS_H
#define __ASM_GENERIC_CODETAG_LDS_H #define __ASM_GENERIC_CODETAG_LDS_H
#ifdef CONFIG_MEM_ALLOC_PROFILING
#define IF_MEM_ALLOC_PROFILING(...) __VA_ARGS__
#else
#define IF_MEM_ALLOC_PROFILING(...)
#endif
#define SECTION_WITH_BOUNDARIES(_name) \ #define SECTION_WITH_BOUNDARIES(_name) \
. = ALIGN(8); \ . = ALIGN(8); \
__start_##_name = .; \ __start_##_name = .; \
@ -9,7 +15,7 @@
__stop_##_name = .; __stop_##_name = .;
#define CODETAG_SECTIONS() \ #define CODETAG_SECTIONS() \
SECTION_WITH_BOUNDARIES(alloc_tags) IF_MEM_ALLOC_PROFILING(SECTION_WITH_BOUNDARIES(alloc_tags))
#define MOD_SEPARATE_CODETAG_SECTION(_name) \ #define MOD_SEPARATE_CODETAG_SECTION(_name) \
.codetag.##_name : { \ .codetag.##_name : { \
@ -22,6 +28,6 @@
* unload them individually once unused. * unload them individually once unused.
*/ */
#define MOD_SEPARATE_CODETAG_SECTIONS() \ #define MOD_SEPARATE_CODETAG_SECTIONS() \
MOD_SEPARATE_CODETAG_SECTION(alloc_tags) IF_MEM_ALLOC_PROFILING(MOD_SEPARATE_CODETAG_SECTION(alloc_tags))
#endif /* __ASM_GENERIC_CODETAG_LDS_H */ #endif /* __ASM_GENERIC_CODETAG_LDS_H */