[PATCH 0/2] RESEND vmlinux.lds.h tweaks

Jim Cromie posted 2 patches 3 years, 5 months ago
include/asm-generic/vmlinux.lds.h | 221 +++++++++++-------------------
1 file changed, 81 insertions(+), 140 deletions(-)
[PATCH 0/2] RESEND vmlinux.lds.h tweaks
Posted by Jim Cromie 3 years, 5 months ago
hi Greg,

this time w/o the stale patch 2.

These 2 patches are "no functional change", but they are a simple step
towards de-duplicating the repetitive columms in the __dyndbg section.

For a DYNAMIC_DEBUG=y kernel with 5k pr_debugs/drm.debugs, the
footprint reduction should be ~100 KiB

Jim Cromie (2):
  vmlinux.lds.h: add BOUNDED_SECTION* macros
  vmlinux.lds.h: place optional header space in BOUNDED_SECTION

 include/asm-generic/vmlinux.lds.h | 221 +++++++++++-------------------
 1 file changed, 81 insertions(+), 140 deletions(-)

CC: Suren Baghdasaryan <surenb@google.com>
CC: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>

-- 
2.37.3
Re: [PATCH 0/2] RESEND vmlinux.lds.h tweaks
Posted by Greg KH 3 years, 4 months ago
On Sat, Oct 22, 2022 at 04:56:35PM -0600, Jim Cromie wrote:
> hi Greg,
> 
> this time w/o the stale patch 2.
> 
> These 2 patches are "no functional change", but they are a simple step
> towards de-duplicating the repetitive columms in the __dyndbg section.
> 
> For a DYNAMIC_DEBUG=y kernel with 5k pr_debugs/drm.debugs, the
> footprint reduction should be ~100 KiB

Cool stuff, let me add it to my tree and see what breaks!  :)

greg k-h
Re: [PATCH 0/2] RESEND vmlinux.lds.h tweaks
Posted by jim.cromie@gmail.com 3 years, 4 months ago
On Thu, Nov 10, 2022 at 11:09 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Sat, Oct 22, 2022 at 04:56:35PM -0600, Jim Cromie wrote:
> > hi Greg,
> >
> > this time w/o the stale patch 2.
> >
> > These 2 patches are "no functional change", but they are a simple step
> > towards de-duplicating the repetitive columms in the __dyndbg section.
> >
> > For a DYNAMIC_DEBUG=y kernel with 5k pr_debugs/drm.debugs, the
> > footprint reduction should be ~100 KiB
>
> Cool stuff, let me add it to my tree and see what breaks!  :)
>
> greg k-h

very good, thnks.

on a rev2, I'd change _s_ _e_ macro vars,
maybe _BEGIN_, _END_, or _1ST_, _LAST_

and maybe expand the commit-msgs for more explanation.
[driver-core-next] vmlinux.lds.h fix
Posted by Jim Cromie 3 years, 4 months ago
hi Greg,

You recently applied to driver-core-next: 2 vmlinux.lds.h patches from
me.  The 2nd has a subtle error, placing the optional header KEEP in
with the data.

1st patch fixes it by dropping the extra KEEP, restoring basic behavior.

2nd redoes the HEADERD_SECTION idea with separate macros, so it cant
affect the basic case.  HEADERD_SECTION is not the name in code, maybe
it should be ?

Also, 2nd is NOT in real/purposeful use yet.

I should have stared at this patchset longer before sending.
sorry about that.

Jim Cromie (2):
  vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
  vmlinux.lds.h: add BOUNDED_SECTION_(PRE|POST)_LABEL_HDR macros

 include/asm-generic/vmlinux.lds.h | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

-- 
2.38.1
[PATCH 1/2] vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
Posted by Jim Cromie 3 years, 4 months ago
commit foo added BOUNDED_SECTION_(PRE|POST)_LABEL macros,
encapsulating the basic boilerplate to: KEEP/pack records into a
section, and to mark the begin and end of the section with
linker-symbols.

But it tried to do extra, adding KEEP(*(.gnu.linkonce.##_sec_)) to
optionally reserve a header record in front of the data.  It wrongly
placed the KEEP after the linker-symbol starting the section,
so if a header was added, it would wind up in the data.

Putting the KEEP in the "correct" place proved brittle, and too clever
by half.  The obvious safe fix is to remove the KEEP, and provide
separate macros to do the extra work.

While here, the macro var-names: _s_, _e_ are nearly invisible, change
them to more obvious names: _BEGIN_, _END_

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/asm-generic/vmlinux.lds.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 50851425b229..85d5d5b203dc 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -199,17 +199,15 @@
 # endif
 #endif
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _s_, _e_)		\
-	_s_##_label_ = .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	_BEGIN_##_label_ = .;						\
 	KEEP(*(_sec_))							\
-	_e_##_label_ = .;
+	_END_##_label_ = .;
 
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _s_, _e_)		\
-	_label_##_s_ = .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	_label_##_BEGIN_ = .;						\
 	KEEP(*(_sec_))							\
-	_label_##_e_ = .;
+	_label_##_END_ = .;
 
 #define BOUNDED_SECTION_BY(_sec_, _label_)				\
 	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
-- 
2.38.1
Re: [PATCH 1/2] vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
Posted by Greg KH 3 years, 4 months ago
On Wed, Nov 16, 2022 at 05:20:21PM -0700, Jim Cromie wrote:
> commit foo added BOUNDED_SECTION_(PRE|POST)_LABEL macros,
> encapsulating the basic boilerplate to: KEEP/pack records into a
> section, and to mark the begin and end of the section with
> linker-symbols.
> 
> But it tried to do extra, adding KEEP(*(.gnu.linkonce.##_sec_)) to
> optionally reserve a header record in front of the data.  It wrongly
> placed the KEEP after the linker-symbol starting the section,
> so if a header was added, it would wind up in the data.
> 
> Putting the KEEP in the "correct" place proved brittle, and too clever
> by half.  The obvious safe fix is to remove the KEEP, and provide
> separate macros to do the extra work.
> 
> While here, the macro var-names: _s_, _e_ are nearly invisible, change
> them to more obvious names: _BEGIN_, _END_
> 
> Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
> ---
>  include/asm-generic/vmlinux.lds.h | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

This change fails to apply to my driver-core-next tree.  Are you sure it
is correct?

confused,

greg k-h
Re: [PATCH 1/2] vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
Posted by jim.cromie@gmail.com 3 years, 4 months ago
On Wed, Nov 16, 2022 at 11:30 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Nov 16, 2022 at 05:20:21PM -0700, Jim Cromie wrote:
> > commit foo added BOUNDED_SECTION_(PRE|POST)_LABEL macros,
> > encapsulating the basic boilerplate to: KEEP/pack records into a
> > section, and to mark the begin and end of the section with
> > linker-symbols.
> >
> > But it tried to do extra, adding KEEP(*(.gnu.linkonce.##_sec_)) to
> > optionally reserve a header record in front of the data.  It wrongly
> > placed the KEEP after the linker-symbol starting the section,
> > so if a header was added, it would wind up in the data.
> >
> > Putting the KEEP in the "correct" place proved brittle, and too clever
> > by half.  The obvious safe fix is to remove the KEEP, and provide
> > separate macros to do the extra work.
> >
> > While here, the macro var-names: _s_, _e_ are nearly invisible, change
> > them to more obvious names: _BEGIN_, _END_
> >
> > Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
> > ---
> >  include/asm-generic/vmlinux.lds.h | 14 ++++++--------
> >  1 file changed, 6 insertions(+), 8 deletions(-)
>
> This change fails to apply to my driver-core-next tree.  Are you sure it
> is correct?
>

meh - it seems I missed a failure of a  git commit --amend,
since im sure I edited a fixes: tag into this commit-msg
or something :-/

I'll send an update shortly,  heres the HEAD of it:

b8b7f5a7a624 (HEAD -> bounded-5) vmlinux.lds.h: add HEADERED_SECTION_* macros
d712ed004b64 vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
f613facc82cf (driver-core/driver-core-testing,
driver-core/driver-core-next) mfd: vexpress-sysreg: Fix resource
compound literal assignments
2f465b921bb8 vmlinux.lds.h: place optional header space in BOUNDED_SECTION
9b351be25360 vmlinux.lds.h: add BOUNDED_SECTION* macros


> confused,
>
> greg k-h
[driver-core-next] vmlinux.lds.h fix (corrected)
Posted by Jim Cromie 3 years, 4 months ago
hi Greg,

Im not quite sure what went wrong with last rev.
Im intrinsically noisy.  Its hard to fix permamently.

1st patch restores basic BOUNDED_SECTION wo header reservation.

2nd redoes the HEADERED_SECTION idea with separate macros, so it cant
affect the basic case.  I havent actually used this yet.

I should have stared at this patchset longer before sending.
sorry about that.

Jim Cromie (2):
  vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
  vmlinux.lds.h: add HEADERED_SECTION_* macros

 include/asm-generic/vmlinux.lds.h | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

-- 
2.38.1
Re: [driver-core-next] vmlinux.lds.h fix (corrected)
Posted by Greg KH 3 years, 4 months ago
On Thu, Nov 17, 2022 at 10:16:31AM -0700, Jim Cromie wrote:
> hi Greg,
> 
> Im not quite sure what went wrong with last rev.
> Im intrinsically noisy.  Its hard to fix permamently.
> 
> 1st patch restores basic BOUNDED_SECTION wo header reservation.
> 
> 2nd redoes the HEADERED_SECTION idea with separate macros, so it cant
> affect the basic case.  I havent actually used this yet.
> 
> I should have stared at this patchset longer before sending.
> sorry about that.

Worked better, thanks, now applied.

greg k-h
[PATCH 1/2] vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
Posted by Jim Cromie 3 years, 4 months ago
Commit 2f465b921bb8 ("vmlinux.lds.h: place optional header space in BOUNDED_SECTION")

added BOUNDED_SECTION_(PRE|POST)_LABEL macros, encapsulating the basic
boilerplate to KEEP/pack records into a section, and to mark the begin
and end of the section with linker-symbols.

But it tried to do extra, adding KEEP(*(.gnu.linkonce.##_sec_)) to
optionally reserve a header record in front of the data.  It wrongly
placed the KEEP after the linker-symbol starting the section,
so if a header was added, it would wind up in the data.

Moving the KEEP to the "correct" place proved brittle, and too clever
by half.  The obvious safe fix is to remove the KEEP and restore the
plain old boilerplate.  The header can be added later, with separate
macros.

Also, the macro var-names: _s_, _e_ are nearly invisible, change them
to more obvious names: _BEGIN_, _END_

Fixes: 2f465b921bb8 ("vmlinux.lds.h: place optional header space in BOUNDED_SECTION")
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/asm-generic/vmlinux.lds.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index b3ca56ac163f..c17f94785253 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -193,17 +193,15 @@
 # endif
 #endif
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _s_, _e_)		\
-	_s_##_label_ = .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	_BEGIN_##_label_ = .;						\
 	KEEP(*(_sec_))							\
-	_e_##_label_ = .;
+	_END_##_label_ = .;
 
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _s_, _e_)		\
-	_label_##_s_ = .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	_label_##_BEGIN_ = .;						\
 	KEEP(*(_sec_))							\
-	_label_##_e_ = .;
+	_label_##_END_ = .;
 
 #define BOUNDED_SECTION_BY(_sec_, _label_)				\
 	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
-- 
2.38.1
[PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros
Posted by Jim Cromie 3 years, 4 months ago
These macros elaborate on BOUNDED_SECTION_(PRE|POST)_LABEL macros,
prepending an optional KEEP(.gnu.linkonce##_sec_) reservation, and a
linker-symbol to address it.

This allows a developer to define a header struct (which must fit with
the section's base struct-type), and could contain:

1- fields whose value is common to the entire set of data-records.
   This allows the header & data structs to specialize, complement
   each other, and shrink.

2- an uplink pointer to an organizing struct
   which refs other related/sub data-tables
   header record is addressable via the extern'd header linker-symbol

Once the linker-symbols created by the macro are ref'd extern in code,
that code can compute a record's index (ptr - start) in the "primary"
table, then use it to index into the related/sub tables.  Adding a
primary.map_* field foreach sub-table would then allow deduplication
and remapping of that sub-table.

This is aimed at dyndbg's struct _ddebug __dyndbg[] section, whose 3
columns: function, file, module are 50%, 90%, 100% redundant.  The
module column is fully recoverable after dynamic_debug_init() saves it
to each ddebug_table.module as the builtin __dyndbg[] table is parsed.

Given that those 3 columns use 24/56 of a _ddebug record, a dyndbg=y
kernel with ~5k callsites could reduce kernel memory substantially.
Returning that memory to the kernel buddy-allocator? is then possible.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
---
 include/asm-generic/vmlinux.lds.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c17f94785253..c9a475a30803 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -208,6 +208,21 @@
 
 #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
 
+#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_HDR_##_label_	= .;						\
+	KEEP(*(.gnu.linkonce.##_sec_))					\
+	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
+
+#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_label_##_HDR_ = .;						\
+	KEEP(*(.gnu.linkonce.##_sec_))					\
+	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
+
+#define HEADERED_SECTION_BY(_sec_, _label_)				\
+	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
+
+#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
+
 #ifdef CONFIG_TRACE_BRANCH_PROFILING
 #define LIKELY_PROFILE()						\
 	BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)
-- 
2.38.1
[PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros
Posted by Jim Cromie 3 years, 4 months ago
These macros elaborate on BOUNDED_SECTION_(PRE|POST)_LABEL macros,
prepending an optional KEEP(.gnu.linkonce##_sec_) reservation, and a
linker-symbol to address it.

This allows a developer to define a header struct (which must fit with
the section's base struct-type), and could contain:

1- fields whose value is common to the entire set of data-records.
   This allows the header & data structs to specialize, complement
   each other, and shrink.

2- an uplink pointer to an organizing struct
   which refs other related/sub data-tables
   header record is addressable via the extern'd header linker-symbol

Once the linker-symbols created by the macro are ref'd extern in code,
that code can compute a record's index (ptr - start) in the "primary"
table, then use it to index into the related/sub tables.  Adding a
primary.map_* field foreach sub-table would then allow deduplication
and remapping of that sub-table.

This is aimed at dyndbg's struct _ddebug __dyndbg[] section, whose 3
columns: function, file, module are 50%, 90%, 100% redundant.  The
module column is fully recoverable after dynamic_debug_init() saves it
to each ddebug_table.module as the builtin __dyndbg[] table is parsed.

Given that those 3 columns use 24/56 of a prdbg record, a dyndbg=y
kernel with ~5k callsites could save substantially.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
---
 include/asm-generic/vmlinux.lds.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 85d5d5b203dc..a3b6aa30a525 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -214,6 +214,21 @@
 
 #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
 
+#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_HDR_##_label_	= .;						\
+	KEEP(*(.gnu.linkonce.##_sec_))					\
+	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
+
+#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_label_##_HDR_ = .;						\
+	KEEP(*(.gnu.linkonce.##_sec_))					\
+	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
+
+#define HEADERED_SECTION_BY(_sec_, _label_)				\
+	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
+
+#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
+
 #ifdef CONFIG_TRACE_BRANCH_PROFILING
 #define LIKELY_PROFILE()						\
 	BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)
-- 
2.38.1
Re: [PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros
Posted by Alexander Lobakin 3 years, 3 months ago
From: Jim Cromie <jim.cromie@gmail.com>
Date: Wed, 16 Nov 2022 17:20:22 -0700

> These macros elaborate on BOUNDED_SECTION_(PRE|POST)_LABEL macros,
> prepending an optional KEEP(.gnu.linkonce##_sec_) reservation, and a
> linker-symbol to address it.
> 
> This allows a developer to define a header struct (which must fit with
> the section's base struct-type), and could contain:

[...]

> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 85d5d5b203dc..a3b6aa30a525 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -214,6 +214,21 @@
>  
>  #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
>  
> +#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
> +	_HDR_##_label_	= .;						\
> +	KEEP(*(.gnu.linkonce.##_sec_))					\
> +	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
> +
> +#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
> +	_label_##_HDR_ = .;						\
> +	KEEP(*(.gnu.linkonce.##_sec_))					\
> +	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
> +
> +#define HEADERED_SECTION_BY(_sec_, _label_)				\
> +	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)

Now HEADERED_SECTION_PRE_LABEL() takes 5 arguments, but this line
passes only 4 to it. This went unnoticed probably due to that the
macro is not used anywhere, thus can't trigger a compiler error.
Would you prefer to fix it yourself or me to send the fix?[*]

> +
> +#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
> +
>  #ifdef CONFIG_TRACE_BRANCH_PROFILING
>  #define LIKELY_PROFILE()						\
>  	BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)
> -- 
> 2.38.1

[*] If it needs fixing at all -- some people over the MLs say that
    if there's no trigger, then there's nothing to fix :clownface:

Thanks,
Olek
Re: [PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros
Posted by Alexander Lobakin 3 years, 3 months ago
> From: Jim Cromie <jim.cromie@gmail.com>
> Date: Wed, 16 Nov 2022 17:20:22 -0700
> 
> > These macros elaborate on BOUNDED_SECTION_(PRE|POST)_LABEL macros,
> > prepending an optional KEEP(.gnu.linkonce##_sec_) reservation, and a
> > linker-symbol to address it.
> > 
> > This allows a developer to define a header struct (which must fit with
> > the section's base struct-type), and could contain:
> 
> [...]
> 
> > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> > index 85d5d5b203dc..a3b6aa30a525 100644
> > --- a/include/asm-generic/vmlinux.lds.h
> > +++ b/include/asm-generic/vmlinux.lds.h
> > @@ -214,6 +214,21 @@
> >  
> >  #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
> >  

Also, those two pasting ops below:

> > +#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
> > +	_HDR_##_label_	= .;						\
> > +	KEEP(*(.gnu.linkonce.##_sec_))					\

                             ^^

> > +	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
> > +
> > +#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
> > +	_label_##_HDR_ = .;						\
> > +	KEEP(*(.gnu.linkonce.##_sec_))					\

                             ^^

will produce incorrect results when @_sec_ starts with a dot (not
a rare thing for section names):

	HEADERED_SECTION_BY(.entry_sites, _entry_sites)

vmlinux.map:

.entry_sites    0xffffffff83c89ca0    0x37118 load address 0x0000000003c89ca0
                0xffffffff83c89ca0                __header_entry_sites = .
 *(.gnu.linkonce. .entry_sites)

here            ^^^

 .entry_sites   0xffffffff83c89ca0    0x37118 vmlinux.o
                0xffffffff83cc0db8                __start_entry_sites = .
 *(.entry_sites)
                0xffffffff83cc0db8                __stop_entry_sites = .

^ as a result, all .entry_sites entries went to the "header" instead
of the "body".

Sorta dangerous stuff as for me, maybe that could be handled
differently?

> > +	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
> > +
> > +#define HEADERED_SECTION_BY(_sec_, _label_)				\
> > +	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
> 
> Now HEADERED_SECTION_PRE_LABEL() takes 5 arguments, but this line
> passes only 4 to it. This went unnoticed probably due to that the
> macro is not used anywhere, thus can't trigger a compiler error.
> Would you prefer to fix it yourself or me to send the fix?[*]
> 
> > +
> > +#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
> > +
> >  #ifdef CONFIG_TRACE_BRANCH_PROFILING
> >  #define LIKELY_PROFILE()						\
> >  	BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)
> > -- 
> > 2.38.1
> 
> [*] If it needs fixing at all -- some people over the MLs say that
>     if there's no trigger, then there's nothing to fix :clownface:
> 
> Thanks,
> Olek

Thanks,
Olek