9c8e2f6d3d36 for linux-4.{4,9,14,19}-y
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.
scripts/recordmcount.c +1 -1
@@ -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
Greg KH
maintainerQuoted 24 lines · Manoj Gupta
Dear stable kernel maintainers,
Please consider applying the following patch for 4.{4,9,14,19}-y kernel branches.
9c8e2f6d3d36scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section namesIt is needed to fix a kernel boot issue with trunk clang compiler which now puts functions with
__coldattribute to .text.unlikely section. Please feel free to check
https://bugs.chromium.org/p/chromium/issues/detail?id=1184483 for details.
9c8e2f6d3d36applies cleanly for 4.14 and 4.19.
For 4.4 and 4.9, a slight changed diff forscripts/recordmcount.cis needed to apply the patch cleanly. The final changed lines are still the same.
scripts/recordmcount.cdiff for 4.4 and 4.9 kernel.
scripts/recordmcount.c static uint32_t (*w2)(uint16_t); · line 368
Quoted 8 lines
scripts/recordmcount.c +1
-1@@ -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
PATCH 1/1 scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
In reply to Manoj GuptaFrom: Joe Lawrence <[email protected]>
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.textAdjust 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
--- scripts/recordmcount.c | 2 +- scripts/recordmcount.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
scripts/recordmcount.c +1 -1
@@ -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 ||
scripts/recordmcount.pl +13 -0
@@ -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();
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
Re: [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
Quoted 84 lines · Manoj Gupta
From: Joe Lawrence <[email protected]>
commit
9c8e2f6d3d361439cc6744a094f1c15681b55269upstream.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()andtest_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.textAdjust the recordmcount scripts to look for ".text" as a section name prefix. This will ensure that those functions will be included in the
__mcount_locrelocations:% 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.textSigned-off-by Joe Lawrence <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>[nc: Resolve conflict because of missing 42c269c88dc146982a54a8267f71abc99f12852a]Signed-off-by Manoj Gupta <[email protected]>--- scripts/recordmcount.c | 2 +- scripts/recordmcount.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)scripts/recordmcount.c +1
-1@@ -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 ||scripts/recordmcount.pl +13
-1@@ -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(); --
Quoted 2 lines
2.31.0.rc2.261.g7f71774620-goog
This patch should apply cleanly to 4.4.y and 4.9.y branches.
Thanks,
Manoj
Re: [PATCH] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
In reply to Manoj GuptaQuoted 27 lines · Manoj Gupta
From: Joe Lawrence <[email protected]>
commit
9c8e2f6d3d361439cc6744a094f1c15681b55269upstream.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()andtest_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.textAdjust the recordmcount scripts to look for ".text" as a section name prefix. This will ensure that those functions will be included in the
__mcount_locrelocations:% 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
Quoted 6 lines
Signed-off-by Joe Lawrence <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>[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.
Quoted 53 lines
Signed-off-by Manoj Gupta <[email protected]>--- scripts/recordmcount.c | 2 +- scripts/recordmcount.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)scripts/recordmcount.c +1
-1@@ -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 ||scripts/recordmcount.pl +13
-1@@ -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
Signature · 2 lines
Thanks, ~Nick Desaulniers
PATCH v2 1/1 scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
In reply to Manoj GuptaFrom: Joe Lawrence <[email protected]>
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.textAdjust 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
---
Changes v1 -> v2:
Change "nc" to "Manoj"
scripts/recordmcount.c | 2 +- scripts/recordmcount.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
scripts/recordmcount.c +1 -1
@@ -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 ||
scripts/recordmcount.pl +13 -0
@@ -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();
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
Greg KH
maintainerRe: [PATCH v2] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names
Quoted 31 lines · Manoj Gupta
From: Joe Lawrence <[email protected]>
commit
9c8e2f6d3d361439cc6744a094f1c15681b55269upstream.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()andtest_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.textAdjust the recordmcount scripts to look for ".text" as a section name prefix. This will ensure that those functions will be included in the
__mcount_locrelocations:% 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.textSigned-off-by Joe Lawrence <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>
Quoted 6 lines
[Manoj: Resolve conflict on 4.4.y/4.9.y because of missing 42c269c88dc1]Signed-off-by Manoj Gupta <[email protected]>---
Changes v1 -> v2:
Change "nc" to "Manoj"
Now queued up, thanks.
greg k-h