kbuild: Disable extra debugging info in .s output
PATCH 1/1 kbuild: Disable extra debugging info in .s output
From: Borislav Petkov <[email protected]>
Modern gcc adds view assignments, reset assertion checking in .loc directives and a couple more additional debug markers, which clutters the asm output unnecessarily:
For example:
bsp_resume:
.LFB3466:
.loc 1 1868 1 is_stmt 1 view -0
.cfi_startproc
.loc 1 1869 2 view .LVU73
# arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 14 is_stmt 0 view .LVU74
movq this_cpu(%rip), %rax # this_cpu, this_cpu
movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5 view .LVU75
testq %rax, %rax # _2
je .L8 #,
.loc 1 1870 3 is_stmt 1 view .LVU76
movq $boot_cpu_data, %rdi #,
jmp __x86_indirect_thunk_rax
or
.loc 2 57 9 view .LVU478
.loc 2 57 9 view .LVU479
.loc 2 57 9 view .LVU480
.loc 2 57 9 view .LVU481
.LBB1385:
.LBB1383:
.LBB1379:
.LBB1377:
.LBB1375:
.loc 2 57 9 view .LVU482
.loc 2 57 9 view .LVU483
movl %edi, %edx # cpu, cpu
.LVL87:
.loc 2 57 9 is_stmt 0 view .LVU484
That MOV in there is drowned in debugging information and latter makes it hard to follow the asm. And that DWARF info is not really needed for asm output staring.
Disable the debug information generation which clutters the asm output unnecessarily:
bsp_resume:
.LFB3466:
.loc 1 1868 1
# arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 14
movq this_cpu(%rip), %rax # this_cpu, this_cpu
movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5
testq %rax, %rax # _2
je .L8 #,
# arch/x86/kernel/cpu/common.c:1870: this_cpu->c_bsp_resume(&boot_cpu_data);
.loc 1 1870 3
movq $boot_cpu_data, %rdi #,
jmp __x86_indirect_thunk_rax
--- scripts/Makefile.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/Makefile.build +5 -1
@@ -103,8 +103,12 @@ modkern_cflags = \ $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) quiet_modtag = $(if $(part-of-module),[M], ) +disable_extra_cc_dbg := $(call cc-option,-gno-as-locview-support) +disable_extra_cc_dbg += $(call cc-option,-fno-dwarf2-cfi-asm) +disable_extra_cc_dbg += $(call cc-option,-feliminate-unused-debug-symbols) +disable_extra_cc_dbg += $(call cc-option,-gno-statement-frontiers) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) $(disable_extra_cc_dbg) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)
Signature · 1 line
2.19.1
Ping?
Quoted 93 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Modern gcc adds view assignments, reset assertion checking in .loc directives and a couple more additional debug markers, which clutters the asm output unnecessarily:
For example:
bsp_resume:
.LFB3466:.loc 1 1868 1 is_stmt 1 view -0 .cfi_startproc .loc 1 1869 2 view .LVU73 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume) .loc 1 1869 14 is_stmt 0 view .LVU74 movq this_cpu(%rip), %rax # this_cpu, this_cpu movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2#
arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5 view .LVU75
testq %rax, %rax # _2
je .L8 #,
.loc 1 1870 3is_stmt1 view .LVU76
movq $boot_cpu_data, %rdi #,
jmp__x86_indirect_thunk_raxor
.loc 2 57 9 view .LVU478
.loc 2 57 9 view .LVU479
.loc 2 57 9 view .LVU480
.loc 2 57 9 view .LVU481
.LBB1385:
.LBB1383:
.LBB1379:
.LBB1377:
.LBB1375:
.loc 2 57 9 view .LVU482
.loc 2 57 9 view .LVU483
movl %edi, %edx # cpu, cpu
.LVL87:
.loc 2 57 9is_stmt0 view .LVU484That MOV in there is drowned in debugging information and latter makes it hard to follow the asm. And that DWARF info is not really needed for asm output staring.
Disable the debug information generation which clutters the asm output unnecessarily:
bsp_resume:
.LFB3466:.loc 1 1868 1 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume) .loc 1 1869 14 movq this_cpu(%rip), %rax # this_cpu, this_cpu movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2#
arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5
testq %rax, %rax # _2
je .L8 #,
#arch/x86/kernel/cpu/common.c:1870:this_cpu->c_bsp_resume(&boot_cpu_data);
.loc 1 1870 3
movq $boot_cpu_data, %rdi #,
jmp__x86_indirect_thunk_raxSigned-off-by Borislav Petkov <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Michal Marek <[email protected]>--- scripts/Makefile.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)scripts/Makefile.build +5
-1@@ -103,8 +103,12 @@ modkern_cflags = \ $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) quiet_modtag = $(if $(part-of-module),[M], ) +disable_extra_cc_dbg := $(call cc-option,-gno-as-locview-support) +disable_extra_cc_dbg += $(call cc-option,-fno-dwarf2-cfi-asm) +disable_extra_cc_dbg += $(call cc-option,-feliminate-unused-debug-symbols) +disable_extra_cc_dbg += $(call cc-option,-gno-statement-frontiers) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) $(disable_extra_cc_dbg) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)Signature · 1 line
2.19.1
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 84 lines · Borislav Petkov
Ping?
Quoted 80 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Modern gcc adds view assignments, reset assertion checking in .loc directives and a couple more additional debug markers, which clutters the asm output unnecessarily:
For example:
bsp_resume:
.LFB3466:.loc 1 1868 1 is_stmt 1 view -0 .cfi_startproc .loc 1 1869 2 view .LVU73 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume) .loc 1 1869 14 is_stmt 0 view .LVU74 movq this_cpu(%rip), %rax # this_cpu, this_cpu movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2#
arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5 view .LVU75
testq %rax, %rax # _2
je .L8 #,
.loc 1 1870 3is_stmt1 view .LVU76
movq $boot_cpu_data, %rdi #,
jmp__x86_indirect_thunk_raxor
.loc 2 57 9 view .LVU478 .loc 2 57 9 view .LVU479 .loc 2 57 9 view .LVU480 .loc 2 57 9 view .LVU481 .LBB1385: .LBB1383: .LBB1379: .LBB1377: .LBB1375: .loc 2 57 9 view .LVU482 .loc 2 57 9 view .LVU483 movl %edi, %edx # cpu, cpu .LVL87: .loc 2 57 9 is_stmt 0 view .LVU484That MOV in there is drowned in debugging information and latter makes it hard to follow the asm. And that DWARF info is not really needed for asm output staring.
Disable the debug information generation which clutters the asm output unnecessarily:
bsp_resume:
.LFB3466:.loc 1 1868 1 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume) .loc 1 1869 14 movq this_cpu(%rip), %rax # this_cpu, this_cpu movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2#
arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5
testq %rax, %rax # _2
je .L8 #,
#arch/x86/kernel/cpu/common.c:1870:this_cpu->c_bsp_resume(&boot_cpu_data);
.loc 1 1870 3
movq $boot_cpu_data, %rdi #,
jmp__x86_indirect_thunk_raxSigned-off-by Borislav Petkov <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Michal Marek <[email protected]>--- scripts/Makefile.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)scripts/Makefile.build +0
-0@@ -103,8 +103,12 @@ modkern_cflags = \ $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) quiet_modtag = $(if $(part-of-module),[M], )
Quoted 4 lines
scripts/Makefile.build modkern_cflags = \ · line 109
Quoted 4 lines
scripts/Makefile.build +4
-0+disable_extra_cc_dbg := $(call cc-option,-gno-as-locview-support) +disable_extra_cc_dbg += $(call cc-option,-fno-dwarf2-cfi-asm) +disable_extra_cc_dbg += $(call cc-option,-feliminate-unused-debug-symbols) +disable_extra_cc_dbg += $(call cc-option,-gno-statement-frontiers)
This would make the build speed slower
because the compiler is invoked to check those flags in every directory.
I tested this patch with x86_64_defconfig and GCC 8.2 (on ubuntu 18.10 in docker)
but I saw no effect of this patch.
CONFIG_DEBUG_INFO adds dwarf info, and clutters asm output.
Did you enable CONFIG_DEBUG_INFO
when you were debugging asm files?
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 6 lines · Masahiro Yamada
This would make the build speed slower
because the compiler is invoked to check those flags in every directory.I tested this patch with
x86_64_defconfigand GCC 8.2 (on ubuntu 18.10 in docker)
but I saw no effect of this patch.
Yes, because that's the .s target which is meant to be used to convert only a *single* .c file to assembly in order to stare at the resulting asm. For example:
make arch/x86/kernel/cpu/common.s
It is a debugging aid - and a very basic and important one - and is not usually used during a normal kernel build. AFAIK.
So we shouldn't worry about any slowdowns here.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 9 lines · Borislav Petkov
Quoted 6 lines · Masahiro Yamada
This would make the build speed slower
because the compiler is invoked to check those flags in every directory.I tested this patch with
x86_64_defconfigand GCC 8.2 (on ubuntu 18.10 in docker)
but I saw no effect of this patch.
Quoted 5 lines
Yes, because that's the .s target which is meant to be used to convert only a *single* .c file to assembly in order to stare at the resulting asm. For example:
make
arch/x86/kernel/cpu/common.s
I do know this, and did compare the output
from the *single* target "make arch/x86/kernel/cpu/common.s"
Quoted 4 lines
It is a debugging aid - and a very basic and important one - and is not usually used during a normal kernel build. AFAIK.
So we shouldn't worry about any slowdowns here.
Your patch does slowdown the build system extremely.
I provide the result of "perf stat" of the incremental build for you.
Without your patch:
Performance counter stats for 'make -j8' (20 runs):
2.721312445 seconds time elapsed
( +- 1.02% )With you patch:
Performance counter stats for 'make -j8' (20 runs):
5.038521415 seconds time elapsed
( +- 0.56% )Why should the normal build affected by the debugging aid?
One more thing, you did not answer my question.
If you are complaining about the DWARF info
enabled by CONFIG_DEBUG_INFO,
I recommend to turn off CONFIG_DEBUG_INFO.
Quoted 7 lines
Thx.
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
--
Best Regards
Masahiro Yamada
Quoted 1 line · Masahiro Yamada
Why should the normal build affected by the debugging aid?
Hmm, ok, so then that target really is being used during the normal build. I don't know why yet so I'll have to do some more staring.
Quoted 5 lines
One more thing, you did not answer my question.
If you are complaining about the DWARF info
enabled byCONFIG_DEBUG_INFO,
I recommend to turn offCONFIG_DEBUG_INFO.
Yes but I don't want to be changing .config just so that I can look at the asm output.
I'll think about a better solution.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 1 line · Masahiro Yamada
I provide the result of "perf stat" of the incremental build for you.
One more question: what exactly is that "incremental build" you're measuring with?
Exact command line please.
Quoted 10 lines
Without your patch:
Performance counter stats for 'make -j8' (20 runs):
2.721312445 seconds time elapsed ( +- 1.02% )
Quoted 7 lines
With you patch:
Performance counter stats for 'make -j8' (20 runs):
5.038521415 seconds time elapsed ( +- 0.56% )
This can't be a full kernel build.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 1 line · Borislav Petkov
This can't be a full kernel build.
So I did this:
$(obj)/%.s: $(src)/%.c FORCE
@echo "HERE\n"
$(call if_changed_dep,cc_s_c)and did a full kernel build with my .config. I got exactly *three* "HERE"s in the build log.
So pls explain in more detail how you're measuring that slowdown.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 6 lines · Borislav Petkov
Quoted 1 line · Masahiro Yamada
I provide the result of "perf stat" of the incremental build for you.
One more question: what exactly is that "incremental build" you're measuring with?
I meant "make" after you the full build
Quoted 1 line
Exact command line please.
$ make defconfig $ make -j8
[Wait until the full build finished]
$ perf stat --repeat 20 --null make -j8
[Wait until the perf result is displayed]
Quoted 20 lines
Quoted 10 lines
Without your patch:
Performance counter stats for 'make -j8' (20 runs):
2.721312445 seconds time elapsed ( +- 1.02% )Quoted 7 lines
With you patch:
Performance counter stats for 'make -j8' (20 runs):
5.038521415 seconds time elapsed ( +- 0.56% )This can't be a full kernel build.
Quoted 7 lines
Thx.
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
--
Best Regards
Masahiro Yamada
Quoted 7 lines · Borislav Petkov
Quoted 1 line · Masahiro Yamada
Why should the normal build affected by the debugging aid?
Hmm, ok, so then that target really is being used during the normal build. I don't know why yet so I'll have to do some more staring.
Quoted 8 lines
Quoted 5 lines
One more thing, you did not answer my question.
If you are complaining about the DWARF info
enabled byCONFIG_DEBUG_INFO,
I recommend to turn offCONFIG_DEBUG_INFO.Yes but I don't want to be changing .config just so that I can look at the asm output.
Generally speaking, the build system should do what was requested by a set of CONFIG options.
If you want to turn off DWARF info,
you should disable the corresponding CONFIG.
If you want to tweak the behavior from the command line, KCFLAGS is available though.
make arch/x86/kernel/cpu/common.s KCFLAGS="-gno-as-locview-support -fno-dwarf2-cfi-asm -feliminate-unused-debug-symbols -gno-statement-frontiers"
Quoted 9 lines
I'll think about a better solution.
Thx.
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 6 lines · Borislav Petkov
Quoted 1 line · Borislav Petkov
This can't be a full kernel build.
So I did this:
Quoted 8 lines
$(obj)/%.s: $(src)/%.c FORCE
@echo "HERE\n" $(call if_changed_dep,cc_s_c)and did a full kernel build with my .config. I got exactly *three* "HERE"s in the build log.
So pls explain in more detail how you're measuring that slowdown.
Variables assigned with ':=' are evaluated just on parsing Makefile.
The scripts/Makefile.build is parsed over and over again, so the compiler is invoked hundreds times to test these four options even when you are not actually building any new objects.
It is mitigated by replacing ':=' with '=',
but they are still evaluated multiple times when generating asm-offset.
Frankly, you cannot use cc-option in scripts/Makefile.build
Your next question might be,
"Is it OK to implement this in the top Makefile?"
It would be better, but I am not convinced to do it.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 8 lines · Masahiro Yamada
Variables assigned with ':=' are evaluated just on parsing
Makefile.The
scripts/Makefile.buildis parsed over and over again, so the compiler is invoked hundreds times to test these four options even when you are not actually building any new objects.It is mitigated by replacing ':=' with '=',
but they are still evaluated multiple times when generating asm-offset.
Now that you mention it, how about ?=
disable_extra_cc_dbg ?= $(call cc-option,-gno-as-locview-support) disable_extra_cc_dbg += $(call cc-option,-fno-dwarf2-cfi-asm) disable_extra_cc_dbg += $(call cc-option,-feliminate-unused-debug-symbols) disable_extra_cc_dbg += $(call cc-option,-gno-statement-frontiers)
With it, the slowdown of the incremental build is ~0.2s (on an old laptop):
defconfig without: 9.6128 +- 0.0327 seconds time elapsed ( +- 0.34% )
vs
defconfig with: 9.8483 +- 0.0273 seconds time elapsed ( +- 0.28% )
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 4 lines · Borislav Petkov
Quoted 2 lines · Masahiro Yamada
Variables assigned with ':=' are evaluated just on parsing
Makefile.
Quoted 8 lines
Quoted 6 lines
The
scripts/Makefile.buildis parsed over and over again, so the compiler is invoked hundreds times to test these four options even when you are not actually building any new objects.It is mitigated by replacing ':=' with '=',
but they are still evaluated multiple times when generating asm-offset.Now that you mention it, how about ?=
'?=' is the same as '=' here.
Quoted 19 lines
disable_extra_cc_dbg?= $(call cc-option,-gno-as-locview-support)disable_extra_cc_dbg+= $(call cc-option,-fno-dwarf2-cfi-asm)disable_extra_cc_dbg+= $(call cc-option,-feliminate-unused-debug-symbols)disable_extra_cc_dbg+= $(call cc-option,-gno-statement-frontiers)With it, the slowdown of the incremental build is ~0.2s (on an old laptop):
defconfig without: 9.6128 +- 0.0327 seconds time elapsed ( +- 0.34% )
vs
defconfig with: 9.8483 +- 0.0273 seconds time elapsed ( +- 0.28% )
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 1 line · Masahiro Yamada
'?=' is the same as '=' here.
Sure but if the slowdown disappears, then make does something else for '?=' apparently vs for '='.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 5 lines · Borislav Petkov
Quoted 1 line · Masahiro Yamada
'?=' is the same as '=' here.
Sure but if the slowdown disappears, then make does something else for '?=' apparently vs for '='.
Ok, let me ask a different question then: would a separate target which will be used to generate only clean asm for debugging purposes ala
make <path-to-file>.asm
or so be an acceptable approach?
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 7 lines · Borislav Petkov
Quoted 5 lines · Borislav Petkov
Quoted 1 line · Masahiro Yamada
'?=' is the same as '=' here.
Sure but if the slowdown disappears, then make does something else for '?=' apparently vs for '='.
'=' and '?=' are the same in the sense that
the right-hand side is evaluated when it is used.
Quoted 4 lines
Ok, let me ask a different question then: would a separate target which will be used to generate only clean asm for debugging purposes ala
make <path-to-file>.asm
Sorry, I do not like to duplicate the code.
I do not understand why you need to test such complicated compiler flags in order to negate CONFIG_DEBUG_INFO.
I am still wondering,
but if this is really worth doing in upstream code, I think the following is a simpler idea.
Makefile +8 -5
@@ -729,25 +729,28 @@ KBUILD_CFLAGS += -fomit-frame-pointer endif endif -KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) +DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments) ifdef CONFIG_DEBUG_INFO ifdef CONFIG_DEBUG_INFO_SPLIT -KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) +DEBUG_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) else -KBUILD_CFLAGS += -g +DEBUG_CFLAGS += -g endif KBUILD_AFLAGS += -Wa,-gdwarf-2 endif ifdef CONFIG_DEBUG_INFO_DWARF4 -KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) +DEBUG_CFLAGS += $(call cc-option, -gdwarf-4,) endif ifdef CONFIG_DEBUG_INFO_REDUCED -KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ +DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) endif +KBUILD_CFLAGS += $(DEBUG_CFLAGS) +export DEBUG_CFLAGS + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FTRACE_MCOUNT_RECORD # gcc 5 supports generating the mcount tables directly
scripts/Makefile.build +1 -1
@@ -104,7 +104,7 @@ modkern_cflags = \ quiet_modtag = $(if $(part-of-module),[M], ) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags))
$(DISABLE_LTO) -fverbose-asm -S -o $@ $<
$(obj)/%.s: $(src)/%.c FORCE
$(call if_changed_dep,cc_s_c)
Quoted 9 lines
or so be an acceptable approach?
Thx.
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
--
Best Regards
Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
I am still wondering,
but if this is really worth doing in upstream code,
Yes, it is very worth doing it:
make <path-to-file>.s
is one of the basic steps one does when trying to pinpoint the Code:
line in a splat back to the code gcc generated.
Quoted 1 line
I think the following is a simpler idea.
Yes, you can do it this way too but I can't apply it here to play with it because gmail probably corrupted the diff:
checking file Makefile
Hunk #1 FAILED at 729.
1 out of 1 hunk FAILED
checking file scripts/Makefile.build
patch: **** malformed patch at line 98: $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
Please attach the diff or send it from another mail server.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 1 line · Borislav Petkov
Please attach the diff or send it from another mail server.
So you couldn't be bothered to send me an applicable version so I went and typed it in by hand. Thanks. ;-\
Anyway, this variant works too, pls queue it.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Borislav,
Quoted 6 lines · Borislav Petkov
Quoted 1 line · Borislav Petkov
Please attach the diff or send it from another mail server.
So you couldn't be bothered to send me an applicable version so I went and typed it in by hand. Thanks. ;-\
I admit I must fix my unfriendly attitude. Sorry for annoying you.
Quoted 4 lines
Anyway, this variant works too, pls queue it.
Acked-by Borislav Petkov <[email protected]>Tested-by Borislav Petkov <[email protected]>
Could you send v2 as I suggested?
Your commit log describes your motivation perfectly.
(I lost the applicable patch because
I just modified the code locally and pasted it into the previous email.)
Quoted 7 lines
Thx.
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 6 lines · Masahiro Yamada
Could you send v2 as I suggested?
Your commit log describes your motivation perfectly.(I lost the applicable patch because
I just modified the code locally and pasted it into the previous email.)
Sure, here it is.
Thx.
---
From: Masahiro Yamada <[email protected]>
Date: Sun, 25 Nov 2018 23:58:00 +0100
Subject: [PATCH] kbuild: Disable extra debugging info in .s output
Modern gcc adds view assignments, reset assertion checking in .loc directives and a couple more additional debug markers, which clutters the asm output unnecessarily:
For example:
bsp_resume:
.LFB3466:
.loc 1 1868 1 is_stmt 1 view -0
.cfi_startproc
.loc 1 1869 2 view .LVU73
# arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 14 is_stmt 0 view .LVU74
movq this_cpu(%rip), %rax # this_cpu, this_cpu
movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5 view .LVU75
testq %rax, %rax # _2
je .L8 #,
.loc 1 1870 3 is_stmt 1 view .LVU76
movq $boot_cpu_data, %rdi #,
jmp __x86_indirect_thunk_rax
or
.loc 2 57 9 view .LVU478
.loc 2 57 9 view .LVU479
.loc 2 57 9 view .LVU480
.loc 2 57 9 view .LVU481
.LBB1385:
.LBB1383:
.LBB1379:
.LBB1377:
.LBB1375:
.loc 2 57 9 view .LVU482
.loc 2 57 9 view .LVU483
movl %edi, %edx # cpu, cpu
.LVL87:
.loc 2 57 9 is_stmt 0 view .LVU484
That MOV in there is drowned in debugging information and latter makes it hard to follow the asm. And that DWARF info is not really needed for asm output staring.
Disable the debug information generation which clutters the asm output unnecessarily:
bsp_resume:
# arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
movq this_cpu(%rip), %rax # this_cpu, this_cpu
movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2
# arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
testq %rax, %rax # _2
je .L8 #,
# arch/x86/kernel/cpu/common.c:1870: this_cpu->c_bsp_resume(&boot_cpu_data);
movq $boot_cpu_data, %rdi #,
jmp __x86_indirect_thunk_rax
.L8:
# arch/x86/kernel/cpu/common.c:1871: }
rep ret
.size bsp_resume, .-bsp_resume
[ bp: write commit message. ]
--- Makefile | 13 ++++++++----- scripts/Makefile.build | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-)
Makefile +8 -5
@@ -729,25 +729,28 @@ KBUILD_CFLAGS += -fomit-frame-pointer endif endif -KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) +DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments) ifdef CONFIG_DEBUG_INFO ifdef CONFIG_DEBUG_INFO_SPLIT -KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) +DEBUG_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) else -KBUILD_CFLAGS += -g +DEBUG_CFLAGS += -g endif KBUILD_AFLAGS += -Wa,-gdwarf-2 endif ifdef CONFIG_DEBUG_INFO_DWARF4 -KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) +DEBUG_CFLAGS += $(call cc-option, -gdwarf-4,) endif ifdef CONFIG_DEBUG_INFO_REDUCED -KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ +DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) endif +KBUILD_CFLAGS += $(DEBUG_CFLAGS) +export DEBUG_CFLAGS + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FTRACE_MCOUNT_RECORD # gcc 5 supports generating the mcount tables directly
scripts/Makefile.build +1 -1
@@ -104,7 +104,7 @@ modkern_cflags = \ quiet_modtag = $(if $(part-of-module),[M], ) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)
Signature · 7 lines
2.19.1
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 5 lines · Borislav Petkov
Quoted 3 lines · Masahiro Yamada
Could you send v2 as I suggested?
Your commit log describes your motivation perfectly.
Quoted 7 lines
Quoted 3 lines
(I lost the applicable patch because
I just modified the code locally and pasted it into the previous email.)Sure, here it is.
Thx.
Applied to linux-kbuild.
Thanks.
Quoted 136 lines
---
From: Masahiro Yamada <[email protected]>
Date: Sun, 25 Nov 2018 23:58:00 +0100
Subject: [PATCH] kbuild: Disable extra debugging info in .s outputModern gcc adds view assignments, reset assertion checking in .loc directives and a couple more additional debug markers, which clutters the asm output unnecessarily:
For example:
bsp_resume:
.LFB3466:.loc 1 1868 1 is_stmt 1 view -0 .cfi_startproc .loc 1 1869 2 view .LVU73 # arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume) .loc 1 1869 14 is_stmt 0 view .LVU74 movq this_cpu(%rip), %rax # this_cpu, this_cpu movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2#
arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
.loc 1 1869 5 view .LVU75
testq %rax, %rax # _2
je .L8 #,
.loc 1 1870 3is_stmt1 view .LVU76
movq $boot_cpu_data, %rdi #,
jmp__x86_indirect_thunk_raxor
.loc 2 57 9 view .LVU478 .loc 2 57 9 view .LVU479 .loc 2 57 9 view .LVU480 .loc 2 57 9 view .LVU481 .LBB1385: .LBB1383: .LBB1379: .LBB1377: .LBB1375: .loc 2 57 9 view .LVU482 .loc 2 57 9 view .LVU483 movl %edi, %edx # cpu, cpu .LVL87: .loc 2 57 9 is_stmt 0 view .LVU484That MOV in there is drowned in debugging information and latter makes it hard to follow the asm. And that DWARF info is not really needed for asm output staring.
Disable the debug information generation which clutters the asm output unnecessarily:
bsp_resume:
#arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
movqthis_cpu(%rip), %rax #this_cpu,this_cpu
movq 64(%rax), %rax # this_cpu.94_1->c_bsp_resume, _2
#arch/x86/kernel/cpu/common.c:1869: if (this_cpu->c_bsp_resume)
testq %rax, %rax # _2
je .L8 #,
#arch/x86/kernel/cpu/common.c:1870:this_cpu->c_bsp_resume(&boot_cpu_data);
movq $boot_cpu_data, %rdi #,
jmp__x86_indirect_thunk_rax
.L8:
#arch/x86/kernel/cpu/common.c:1871: }
rep ret
.sizebsp_resume, .-bsp_resume[ bp: write commit message. ]
Signed-off-by Masahiro Yamada <[email protected]>Signed-off-by Borislav Petkov <[email protected]>Cc Michal Marek <[email protected]>--- Makefile | 13 ++++++++----- scripts/Makefile.build | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-)Makefile +8
-5@@ -729,25 +729,28 @@ KBUILD_CFLAGS += -fomit-frame-pointer endif endif -KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) +DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments) ifdef CONFIG_DEBUG_INFO ifdef CONFIG_DEBUG_INFO_SPLIT -KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) +DEBUG_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) else -KBUILD_CFLAGS += -g +DEBUG_CFLAGS += -g endif KBUILD_AFLAGS += -Wa,-gdwarf-2 endif ifdef CONFIG_DEBUG_INFO_DWARF4 -KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) +DEBUG_CFLAGS += $(call cc-option, -gdwarf-4,) endif ifdef CONFIG_DEBUG_INFO_REDUCED -KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ +DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) endif +KBUILD_CFLAGS += $(DEBUG_CFLAGS) +export DEBUG_CFLAGS + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FTRACE_MCOUNT_RECORD # gcc 5 supports generating the mcount tables directlyscripts/Makefile.build +1
-2@@ -104,7 +104,7 @@ modkern_cflags = \ quiet_modtag = $(if $(part-of-module),[M], ) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c) --2.19.1
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
Signature · 2 lines
Best Regards Masahiro Yamada