linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] codetag: Avoid unused alloc_tags sections/symbols
@ 2025-06-18 12:50 Petr Pavlu
  2025-06-25 16:07 ` Suren Baghdasaryan
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Pavlu @ 2025-06-18 12:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Suren Baghdasaryan, Kent Overstreet, Arnd Bergmann, Casey Chen,
	linux-arch, linux-modules, linux-kernel, Petr Pavlu

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.

Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Reviewed-by: Kent Overstreet <kent.overstreet@linux.dev>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
---

Changes since v1 [1]:
- Trivially rebased the patch on top of "alloc_tag: remove empty module tag
  section" [2].

[1] https://lore.kernel.org/all/20250313143002.9118-1-petr.pavlu@suse.com/
[2] https://lore.kernel.org/all/20250610162258.324645-1-cachen@purestorage.com/

 include/asm-generic/codetag.lds.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/codetag.lds.h b/include/asm-generic/codetag.lds.h
index a45fe3d141a1..a14f4bdafdda 100644
--- a/include/asm-generic/codetag.lds.h
+++ b/include/asm-generic/codetag.lds.h
@@ -2,6 +2,12 @@
 #ifndef __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)	\
 	. = ALIGN(8);			\
 	__start_##_name = .;		\
@@ -9,7 +15,7 @@
 	__stop_##_name = .;
 
 #define CODETAG_SECTIONS()		\
-	SECTION_WITH_BOUNDARIES(alloc_tags)
+	IF_MEM_ALLOC_PROFILING(SECTION_WITH_BOUNDARIES(alloc_tags))
 
 #define MOD_SEPARATE_CODETAG_SECTION(_name)	\
 	.codetag.##_name : {			\
@@ -22,6 +28,6 @@
  * unload them individually once unused.
  */
 #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 */

base-commit: 52da431bf03b5506203bca27fe14a97895c80faf
prerequisite-patch-id: acb6e2f6708cd75488806308bfecf682b2367dc9
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] codetag: Avoid unused alloc_tags sections/symbols
  2025-06-18 12:50 [PATCH v2] codetag: Avoid unused alloc_tags sections/symbols Petr Pavlu
@ 2025-06-25 16:07 ` Suren Baghdasaryan
  0 siblings, 0 replies; 2+ messages in thread
From: Suren Baghdasaryan @ 2025-06-25 16:07 UTC (permalink / raw)
  To: Petr Pavlu
  Cc: Andrew Morton, Kent Overstreet, Arnd Bergmann, Casey Chen,
	linux-arch, linux-modules, linux-kernel

On Wed, Jun 18, 2025 at 5:50 AM Petr Pavlu <petr.pavlu@suse.com> wrote:
>
> 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.
>
> Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
> Reviewed-by: Kent Overstreet <kent.overstreet@linux.dev>
> Reviewed-by: Suren Baghdasaryan <surenb@google.com>

Thanks!

Acked-by: Suren Baghdasaryan <surenb@google.com>

> ---
>
> Changes since v1 [1]:
> - Trivially rebased the patch on top of "alloc_tag: remove empty module tag
>   section" [2].
>
> [1] https://lore.kernel.org/all/20250313143002.9118-1-petr.pavlu@suse.com/
> [2] https://lore.kernel.org/all/20250610162258.324645-1-cachen@purestorage.com/
>
>  include/asm-generic/codetag.lds.h | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/codetag.lds.h b/include/asm-generic/codetag.lds.h
> index a45fe3d141a1..a14f4bdafdda 100644
> --- a/include/asm-generic/codetag.lds.h
> +++ b/include/asm-generic/codetag.lds.h
> @@ -2,6 +2,12 @@
>  #ifndef __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) \
>         . = ALIGN(8);                   \
>         __start_##_name = .;            \
> @@ -9,7 +15,7 @@
>         __stop_##_name = .;
>
>  #define CODETAG_SECTIONS()             \
> -       SECTION_WITH_BOUNDARIES(alloc_tags)
> +       IF_MEM_ALLOC_PROFILING(SECTION_WITH_BOUNDARIES(alloc_tags))
>
>  #define MOD_SEPARATE_CODETAG_SECTION(_name)    \
>         .codetag.##_name : {                    \
> @@ -22,6 +28,6 @@
>   * unload them individually once unused.
>   */
>  #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 */
>
> base-commit: 52da431bf03b5506203bca27fe14a97895c80faf
> prerequisite-patch-id: acb6e2f6708cd75488806308bfecf682b2367dc9
> --
> 2.49.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-25 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 12:50 [PATCH v2] codetag: Avoid unused alloc_tags sections/symbols Petr Pavlu
2025-06-25 16:07 ` Suren Baghdasaryan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).