* 9c8e2f6d3d36 for linux-4.{4,9,14,19}-y
@ 2021-03-11 1:09 Manoj Gupta
2021-03-12 10:07 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Manoj Gupta @ 2021-03-11 1:09 UTC (permalink / raw)
To: gregkh, sashal
Cc: joe.lawrence, clang-built-linux, stable, Nick Desaulniers,
Luis Lozano, Jian Cai, Doug Anderson
Dear stable kernel maintainers,
Please consider applying the following patch for 4.{4,9,14,19}-y
kernel branches.
9c8e2f6d3d36 scripts/recordmcount.{c,pl}: support -ffunction-sections
.text.* section names
It is needed to fix a kernel boot issue with trunk clang compiler
which now puts functions with __cold attribute to .text.unlikely
section. Please feel free to check
https://bugs.chromium.org/p/chromium/issues/detail?id=1184483 for
details.
9c8e2f6d3d36 applies cleanly for 4.14 and 4.19.
For 4.4 and 4.9, a slight changed diff for scripts/recordmcount.c is
needed to apply the patch cleanly. The final changed lines are still
the same.
scripts/recordmcount.c diff for 4.4 and 4.9 kernel.
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -362,7 +362,7 @@ static uint32_t (*w2)(uint16_t);
static int
is_mcounted_section_name(char const *const txtname)
{
- return strcmp(".text", txtname) == 0 ||
+ return strncmp(".text", txtname, 5) == 0 ||
strcmp(".ref.text", txtname) == 0 ||
strcmp(".sched.text", txtname) == 0 ||
strcmp(".spinlock.text", txtname) == 0 ||
Thanks,
Manoj
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 9c8e2f6d3d36 for linux-4.{4,9,14,19}-y
2021-03-11 1:09 9c8e2f6d3d36 for linux-4.{4,9,14,19}-y Manoj Gupta
@ 2021-03-12 10:07 ` Greg KH
2021-03-12 20:39 ` [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Manoj Gupta
2021-03-12 22:17 ` [PATCH v2] " Manoj Gupta
2 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2021-03-12 10:07 UTC (permalink / raw)
To: Manoj Gupta
Cc: sashal, joe.lawrence, clang-built-linux, stable,
Nick Desaulniers, Luis Lozano, Jian Cai, Doug Anderson
On Wed, Mar 10, 2021 at 05:09:30PM -0800, Manoj Gupta wrote:
> Dear stable kernel maintainers,
>
> Please consider applying the following patch for 4.{4,9,14,19}-y
> kernel branches.
> 9c8e2f6d3d36 scripts/recordmcount.{c,pl}: support -ffunction-sections
> .text.* section names
>
> It is needed to fix a kernel boot issue with trunk clang compiler
> which now puts functions with __cold attribute to .text.unlikely
> section. Please feel free to check
> https://bugs.chromium.org/p/chromium/issues/detail?id=1184483 for
> details.
>
> 9c8e2f6d3d36 applies cleanly for 4.14 and 4.19.
> For 4.4 and 4.9, a slight changed diff for scripts/recordmcount.c is
> needed to apply the patch cleanly. The final changed lines are still
> the same.
>
> scripts/recordmcount.c diff for 4.4 and 4.9 kernel.
>
> --- a/scripts/recordmcount.c
> +++ b/scripts/recordmcount.c
> @@ -362,7 +362,7 @@ static uint32_t (*w2)(uint16_t);
> static int
> is_mcounted_section_name(char const *const txtname)
> {
> - return strcmp(".text", txtname) == 0 ||
> + return strncmp(".text", txtname, 5) == 0 ||
> strcmp(".ref.text", txtname) == 0 ||
> strcmp(".sched.text", txtname) == 0 ||
> strcmp(".spinlock.text", txtname) == 0 ||
>
Can you provide properly backported versions for 4.4 and 4.9 so I can
apply them? Hand-editing them doesn't really work well...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
2021-03-11 1:09 9c8e2f6d3d36 for linux-4.{4,9,14,19}-y Manoj Gupta
2021-03-12 10:07 ` Greg KH
@ 2021-03-12 20:39 ` Manoj Gupta
2021-03-12 20:42 ` Manoj Gupta
2021-03-12 20:52 ` Nick Desaulniers
2021-03-12 22:17 ` [PATCH v2] " Manoj Gupta
2 siblings, 2 replies; 7+ messages in thread
From: Manoj Gupta @ 2021-03-12 20:39 UTC (permalink / raw)
To: gregkh, sashal
Cc: stable, clang-built-linux, ndesaulniers, jiancai, dianders,
llozano, manojgupta, Joe Lawrence, Steven Rostedt
From: Joe Lawrence <joe.lawrence@redhat.com>
commit 9c8e2f6d3d361439cc6744a094f1c15681b55269 upstream.
When building with -ffunction-sections, the compiler will place each
function into its own ELF section, prefixed with ".text". For example,
a simple test module with functions test_module_do_work() and
test_module_wq_func():
% objdump --section-headers test_module.o | awk '/\.text/{print $2}'
.text
.text.test_module_do_work
.text.test_module_wq_func
.init.text
.exit.text
Adjust the recordmcount scripts to look for ".text" as a section name
prefix. This will ensure that those functions will be included in the
__mcount_loc relocations:
% objdump --reloc --section __mcount_loc test_module.o
OFFSET TYPE VALUE
0000000000000000 R_X86_64_64 .text.test_module_do_work
0000000000000008 R_X86_64_64 .text.test_module_wq_func
0000000000000010 R_X86_64_64 .init.text
Link: http://lkml.kernel.org/r/1542745158-25392-2-git-send-email-joe.lawrence@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
[nc: Resolve conflict because of missing 42c269c88dc146982a54a8267f71abc99f12852a]
Signed-off-by: Manoj Gupta <manojgupta@google.com>
---
scripts/recordmcount.c | 2 +-
scripts/recordmcount.pl | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 7250fb38350c..8cba4c44da4c 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -362,7 +362,7 @@ static uint32_t (*w2)(uint16_t);
static int
is_mcounted_section_name(char const *const txtname)
{
- return strcmp(".text", txtname) == 0 ||
+ return strncmp(".text", txtname, 5) == 0 ||
strcmp(".ref.text", txtname) == 0 ||
strcmp(".sched.text", txtname) == 0 ||
strcmp(".spinlock.text", txtname) == 0 ||
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index ccd6614ea218..5ca4ec297019 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -138,6 +138,11 @@ my %text_sections = (
".text.unlikely" => 1,
);
+# Acceptable section-prefixes to record.
+my %text_section_prefixes = (
+ ".text." => 1,
+);
+
# Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
$objdump = 'objdump' if (!$objdump);
$objcopy = 'objcopy' if (!$objcopy);
@@ -503,6 +508,14 @@ while (<IN>) {
# Only record text sections that we know are safe
$read_function = defined($text_sections{$1});
+ if (!$read_function) {
+ foreach my $prefix (keys %text_section_prefixes) {
+ if (substr($1, 0, length $prefix) eq $prefix) {
+ $read_function = 1;
+ last;
+ }
+ }
+ }
# print out any recorded offsets
update_funcs();
--
2.31.0.rc2.261.g7f71774620-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
2021-03-12 20:39 ` [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Manoj Gupta
@ 2021-03-12 20:42 ` Manoj Gupta
2021-03-12 20:52 ` Nick Desaulniers
1 sibling, 0 replies; 7+ messages in thread
From: Manoj Gupta @ 2021-03-12 20:42 UTC (permalink / raw)
To: gregkh, sashal
Cc: stable, clang-built-linux, Nick Desaulniers, Jian Cai,
Doug Anderson, Luis Lozano, Joe Lawrence, Steven Rostedt
On Fri, Mar 12, 2021 at 12:39 PM Manoj Gupta <manojgupta@google.com> wrote:
>
> From: Joe Lawrence <joe.lawrence@redhat.com>
>
> commit 9c8e2f6d3d361439cc6744a094f1c15681b55269 upstream.
>
> When building with -ffunction-sections, the compiler will place each
> function into its own ELF section, prefixed with ".text". For example,
> a simple test module with functions test_module_do_work() and
> test_module_wq_func():
>
> % objdump --section-headers test_module.o | awk '/\.text/{print $2}'
> .text
> .text.test_module_do_work
> .text.test_module_wq_func
> .init.text
> .exit.text
>
> Adjust the recordmcount scripts to look for ".text" as a section name
> prefix. This will ensure that those functions will be included in the
> __mcount_loc relocations:
>
> % objdump --reloc --section __mcount_loc test_module.o
> OFFSET TYPE VALUE
> 0000000000000000 R_X86_64_64 .text.test_module_do_work
> 0000000000000008 R_X86_64_64 .text.test_module_wq_func
> 0000000000000010 R_X86_64_64 .init.text
>
> Link: http://lkml.kernel.org/r/1542745158-25392-2-git-send-email-joe.lawrence@redhat.com
>
> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> [nc: Resolve conflict because of missing 42c269c88dc146982a54a8267f71abc99f12852a]
> Signed-off-by: Manoj Gupta <manojgupta@google.com>
> ---
> scripts/recordmcount.c | 2 +-
> scripts/recordmcount.pl | 13 +++++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
> index 7250fb38350c..8cba4c44da4c 100644
> --- a/scripts/recordmcount.c
> +++ b/scripts/recordmcount.c
> @@ -362,7 +362,7 @@ static uint32_t (*w2)(uint16_t);
> static int
> is_mcounted_section_name(char const *const txtname)
> {
> - return strcmp(".text", txtname) == 0 ||
> + return strncmp(".text", txtname, 5) == 0 ||
> strcmp(".ref.text", txtname) == 0 ||
> strcmp(".sched.text", txtname) == 0 ||
> strcmp(".spinlock.text", txtname) == 0 ||
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index ccd6614ea218..5ca4ec297019 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
> @@ -138,6 +138,11 @@ my %text_sections = (
> ".text.unlikely" => 1,
> );
>
> +# Acceptable section-prefixes to record.
> +my %text_section_prefixes = (
> + ".text." => 1,
> +);
> +
> # Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
> $objdump = 'objdump' if (!$objdump);
> $objcopy = 'objcopy' if (!$objcopy);
> @@ -503,6 +508,14 @@ while (<IN>) {
>
> # Only record text sections that we know are safe
> $read_function = defined($text_sections{$1});
> + if (!$read_function) {
> + foreach my $prefix (keys %text_section_prefixes) {
> + if (substr($1, 0, length $prefix) eq $prefix) {
> + $read_function = 1;
> + last;
> + }
> + }
> + }
> # print out any recorded offsets
> update_funcs();
>
> --
> 2.31.0.rc2.261.g7f71774620-goog
>
This patch should apply cleanly to 4.4.y and 4.9.y branches.
Thanks,
Manoj
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
2021-03-12 20:39 ` [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Manoj Gupta
2021-03-12 20:42 ` Manoj Gupta
@ 2021-03-12 20:52 ` Nick Desaulniers
1 sibling, 0 replies; 7+ messages in thread
From: Nick Desaulniers @ 2021-03-12 20:52 UTC (permalink / raw)
To: Manoj Gupta
Cc: Greg KH, Sasha Levin, # 3.4.x, clang-built-linux, Jian Cai,
Doug Anderson, Luis Lozano, Joe Lawrence, Steven Rostedt
On Fri, Mar 12, 2021 at 12:39 PM Manoj Gupta <manojgupta@google.com> wrote:
>
> From: Joe Lawrence <joe.lawrence@redhat.com>
>
> commit 9c8e2f6d3d361439cc6744a094f1c15681b55269 upstream.
>
> When building with -ffunction-sections, the compiler will place each
> function into its own ELF section, prefixed with ".text". For example,
> a simple test module with functions test_module_do_work() and
> test_module_wq_func():
>
> % objdump --section-headers test_module.o | awk '/\.text/{print $2}'
> .text
> .text.test_module_do_work
> .text.test_module_wq_func
> .init.text
> .exit.text
>
> Adjust the recordmcount scripts to look for ".text" as a section name
> prefix. This will ensure that those functions will be included in the
> __mcount_loc relocations:
>
> % objdump --reloc --section __mcount_loc test_module.o
> OFFSET TYPE VALUE
> 0000000000000000 R_X86_64_64 .text.test_module_do_work
> 0000000000000008 R_X86_64_64 .text.test_module_wq_func
> 0000000000000010 R_X86_64_64 .init.text
>
> Link: http://lkml.kernel.org/r/1542745158-25392-2-git-send-email-joe.lawrence@redhat.com
>
> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> [nc: Resolve conflict because of missing 42c269c88dc146982a54a8267f71abc99f12852a]
^ Isn't `nc:` here supposed to be your initials, ie. `mg:`, or do I
have that wrong?
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
doesn't clarify.
> Signed-off-by: Manoj Gupta <manojgupta@google.com>
> ---
> scripts/recordmcount.c | 2 +-
> scripts/recordmcount.pl | 13 +++++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
> index 7250fb38350c..8cba4c44da4c 100644
> --- a/scripts/recordmcount.c
> +++ b/scripts/recordmcount.c
> @@ -362,7 +362,7 @@ static uint32_t (*w2)(uint16_t);
> static int
> is_mcounted_section_name(char const *const txtname)
> {
> - return strcmp(".text", txtname) == 0 ||
> + return strncmp(".text", txtname, 5) == 0 ||
> strcmp(".ref.text", txtname) == 0 ||
> strcmp(".sched.text", txtname) == 0 ||
> strcmp(".spinlock.text", txtname) == 0 ||
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index ccd6614ea218..5ca4ec297019 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
> @@ -138,6 +138,11 @@ my %text_sections = (
> ".text.unlikely" => 1,
> );
>
> +# Acceptable section-prefixes to record.
> +my %text_section_prefixes = (
> + ".text." => 1,
> +);
> +
> # Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
> $objdump = 'objdump' if (!$objdump);
> $objcopy = 'objcopy' if (!$objcopy);
> @@ -503,6 +508,14 @@ while (<IN>) {
>
> # Only record text sections that we know are safe
> $read_function = defined($text_sections{$1});
> + if (!$read_function) {
> + foreach my $prefix (keys %text_section_prefixes) {
> + if (substr($1, 0, length $prefix) eq $prefix) {
> + $read_function = 1;
> + last;
> + }
> + }
> + }
> # print out any recorded offsets
> update_funcs();
>
> --
> 2.31.0.rc2.261.g7f71774620-goog
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
2021-03-11 1:09 9c8e2f6d3d36 for linux-4.{4,9,14,19}-y Manoj Gupta
2021-03-12 10:07 ` Greg KH
2021-03-12 20:39 ` [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Manoj Gupta
@ 2021-03-12 22:17 ` Manoj Gupta
2021-03-13 13:32 ` Greg KH
2 siblings, 1 reply; 7+ messages in thread
From: Manoj Gupta @ 2021-03-12 22:17 UTC (permalink / raw)
To: stable
Cc: gregkh, sashal, clang-built-linux, ndesaulniers, jiancai,
dianders, llozano, manojgupta, Joe Lawrence, Steven Rostedt
From: Joe Lawrence <joe.lawrence@redhat.com>
commit 9c8e2f6d3d361439cc6744a094f1c15681b55269 upstream.
When building with -ffunction-sections, the compiler will place each
function into its own ELF section, prefixed with ".text". For example,
a simple test module with functions test_module_do_work() and
test_module_wq_func():
% objdump --section-headers test_module.o | awk '/\.text/{print $2}'
.text
.text.test_module_do_work
.text.test_module_wq_func
.init.text
.exit.text
Adjust the recordmcount scripts to look for ".text" as a section name
prefix. This will ensure that those functions will be included in the
__mcount_loc relocations:
% objdump --reloc --section __mcount_loc test_module.o
OFFSET TYPE VALUE
0000000000000000 R_X86_64_64 .text.test_module_do_work
0000000000000008 R_X86_64_64 .text.test_module_wq_func
0000000000000010 R_X86_64_64 .init.text
Link: http://lkml.kernel.org/r/1542745158-25392-2-git-send-email-joe.lawrence@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
[Manoj: Resolve conflict on 4.4.y/4.9.y because of missing 42c269c88dc1]
Signed-off-by: Manoj Gupta <manojgupta@google.com>
---
Changes v1 -> v2:
Change "nc" to "Manoj"
scripts/recordmcount.c | 2 +-
scripts/recordmcount.pl | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 7250fb38350c..8cba4c44da4c 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -362,7 +362,7 @@ static uint32_t (*w2)(uint16_t);
static int
is_mcounted_section_name(char const *const txtname)
{
- return strcmp(".text", txtname) == 0 ||
+ return strncmp(".text", txtname, 5) == 0 ||
strcmp(".ref.text", txtname) == 0 ||
strcmp(".sched.text", txtname) == 0 ||
strcmp(".spinlock.text", txtname) == 0 ||
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index ccd6614ea218..5ca4ec297019 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -138,6 +138,11 @@ my %text_sections = (
".text.unlikely" => 1,
);
+# Acceptable section-prefixes to record.
+my %text_section_prefixes = (
+ ".text." => 1,
+);
+
# Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
$objdump = 'objdump' if (!$objdump);
$objcopy = 'objcopy' if (!$objcopy);
@@ -503,6 +508,14 @@ while (<IN>) {
# Only record text sections that we know are safe
$read_function = defined($text_sections{$1});
+ if (!$read_function) {
+ foreach my $prefix (keys %text_section_prefixes) {
+ if (substr($1, 0, length $prefix) eq $prefix) {
+ $read_function = 1;
+ last;
+ }
+ }
+ }
# print out any recorded offsets
update_funcs();
--
2.31.0.rc2.261.g7f71774620-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
2021-03-12 22:17 ` [PATCH v2] " Manoj Gupta
@ 2021-03-13 13:32 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2021-03-13 13:32 UTC (permalink / raw)
To: Manoj Gupta
Cc: stable, sashal, clang-built-linux, ndesaulniers, jiancai,
dianders, llozano, Joe Lawrence, Steven Rostedt
On Fri, Mar 12, 2021 at 02:17:49PM -0800, Manoj Gupta wrote:
> From: Joe Lawrence <joe.lawrence@redhat.com>
>
> commit 9c8e2f6d3d361439cc6744a094f1c15681b55269 upstream.
>
> When building with -ffunction-sections, the compiler will place each
> function into its own ELF section, prefixed with ".text". For example,
> a simple test module with functions test_module_do_work() and
> test_module_wq_func():
>
> % objdump --section-headers test_module.o | awk '/\.text/{print $2}'
> .text
> .text.test_module_do_work
> .text.test_module_wq_func
> .init.text
> .exit.text
>
> Adjust the recordmcount scripts to look for ".text" as a section name
> prefix. This will ensure that those functions will be included in the
> __mcount_loc relocations:
>
> % objdump --reloc --section __mcount_loc test_module.o
> OFFSET TYPE VALUE
> 0000000000000000 R_X86_64_64 .text.test_module_do_work
> 0000000000000008 R_X86_64_64 .text.test_module_wq_func
> 0000000000000010 R_X86_64_64 .init.text
>
> Link: http://lkml.kernel.org/r/1542745158-25392-2-git-send-email-joe.lawrence@redhat.com
>
> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> [Manoj: Resolve conflict on 4.4.y/4.9.y because of missing 42c269c88dc1]
> Signed-off-by: Manoj Gupta <manojgupta@google.com>
> ---
>
> Changes v1 -> v2:
> Change "nc" to "Manoj"
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-03-13 13:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 1:09 9c8e2f6d3d36 for linux-4.{4,9,14,19}-y Manoj Gupta
2021-03-12 10:07 ` Greg KH
2021-03-12 20:39 ` [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Manoj Gupta
2021-03-12 20:42 ` Manoj Gupta
2021-03-12 20:52 ` Nick Desaulniers
2021-03-12 22:17 ` [PATCH v2] " Manoj Gupta
2021-03-13 13:32 ` Greg KH
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).