KVM: arm64: nvhe: Disable profile optimization
PATCH 1/1 KVM: arm64: nvhe: Disable profile optimization
Kernel build with -fprofile-sample-use raises the following failure:
error: arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: Unexpected SHT_REL section ".rel.llvm.call-graph-profile"
SHT_REL is generated by the latest lld, see
https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086.
Disable profile optimization in kvm/nvhe to fix the build with AutoFDO.
--- arch/arm64/kvm/hyp/nvhe/Makefile | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kvm/hyp/nvhe/Makefile +3 -0
@@ -89,6 +89,9 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +# Profile optimization creates SHT_REL section '.llvm.call-graph-profile' for +# the hot code. SHT_REL is currently not supported by the KVM tools. +KBUILD_CFLAGS += $(call cc-option,-fno-profile-sample-use,-fno-profile-use) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
Signature · 7 lines
2.37.3.968.ga6b4b080e4-goog _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Marc Zyngier
maintainerHi Denis,
Quoted 5 lines · Denis Nikitin
Kernel build with -fprofile-sample-use raises the following failure:
error:
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: UnexpectedSHT_RELsection ".rel.llvm.call-graph-profile"
How is this flag provided? I don't see any occurrence of it in the kernel so far.
Quoted 3 lines
SHT_RELis generated by the latest lld, see
https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086.
Is this part of a released toolchain? If so, can you spell out the first version where this occurs?
Quoted 2 lines
Disable profile optimization in kvm/nvhe to fix the build with AutoFDO.
It'd be good to at least mention how AutoFDO and -fprofile-sample-use relate to each other.
Quoted 11 lines
Signed-off-by Denis Nikitin <[email protected]>--- arch/arm64/kvm/hyp/nvhe/Makefile | 3 +++ 1 file changed, 3 insertions(+)arch/arm64/kvm/hyp/nvhe/Makefile +0
-0
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 93
Quoted 5 lines
arch/arm64/kvm/hyp/nvhe/Makefile +2
-0@@ -89,6 +89,9 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +# Profile optimization creates SHT_REL section '.llvm.call-graph-profile' for +# the hot code. SHT_REL is currently not supported by the KVM tools.
'KVM tools' seems vague. Maybe call out the actual helper that processes the relocations?
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 94
Quoted 1 line
arch/arm64/kvm/hyp/nvhe/Makefile +1
-0+KBUILD_CFLAGS += $(call cc-option,-fno-profile-sample-use,-fno-profile-use)
Why adding these options instead of filtering out the offending option as it is done just above?
Also, is this the only place the kernel fails to compile? The EFI stub does similar things AFAIR, and could potentially fail the same way.
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Hi Mark,
Thank you for a quick response.
Quoted 6 lines · Marc Zyngier
Hi Denis,
Quoted 1 line · Denis Nikitin
Quoted 7 lines
Quoted 4 lines
Kernel build with -fprofile-sample-use raises the following failure:
error:
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: UnexpectedSHT_RELsection ".rel.llvm.call-graph-profile"How is this flag provided? I don't see any occurrence of it in the kernel so far.
On ChromeOS we build the kernel with sample profiles by adding -fprofile-sample-use=/path/to/gcov.profile to KCFLAGS.
Quoted 7 lines
Quoted 4 lines
SHT_RELis generated by the latest lld, see
https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086.Is this part of a released toolchain? If so, can you spell out the first version where this occurs?
Yes, it was added in llvm-13. I will update the patch.
Quoted 6 lines
Quoted 3 lines
Disable profile optimization in kvm/nvhe to fix the build with AutoFDO.
It'd be good to at least mention how AutoFDO and -fprofile-sample-use relate to each other.
Good point. AutoFDO is an example of sample profiles. It's not actually relevant for the bug. I will better remove it.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Denis Nikitin <[email protected]>--- arch/arm64/kvm/hyp/nvhe/Makefile | 3 +++ 1 file changed, 3 insertions(+)
Quoted 13 lines
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 93
Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/Makefile +2
-0@@ -89,6 +89,9 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +# Profile optimization creates SHT_REL section '.llvm.call-graph-profile' for +# the hot code. SHT_REL is currently not supported by the KVM tools.'KVM tools' seems vague. Maybe call out the actual helper that processes the relocations?
Agreed.
Quoted 5 lines
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 94
Quoted 2 lines
arch/arm64/kvm/hyp/nvhe/Makefile +1
-0+KBUILD_CFLAGS += $(call cc-option,-fno-profile-sample-use,-fno-profile-use)Why adding these options instead of filtering out the offending option as it is done just above?
That was actually the alternative solution and it worked as well. Let me double check if profile optimization doesn't mess up with other sections and if it doesn't I will remove the '.llvm.call-graph-profile' section instead.
Quoted 3 lines
Also, is this the only place the kernel fails to compile? The EFI stub does similar things AFAIR, and could potentially fail the same way.
This was the only place in 5.15 where we tested it. Let me see if EFI has this section.
Quoted 7 lines
Thanks,
M.--
Without deviation from the norm, progress is not possible.
Thanks,
Denis
Adding a few more comments...
Quoted 69 lines · Denis Nikitin
Hi Mark,
Thank you for a quick response.
Quoted 6 lines · Marc Zyngier
Hi Denis,
Quoted 1 line · Denis Nikitin
Quoted 7 lines
Quoted 4 lines
Kernel build with -fprofile-sample-use raises the following failure:
error:
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: UnexpectedSHT_RELsection ".rel.llvm.call-graph-profile"How is this flag provided? I don't see any occurrence of it in the kernel so far.
On ChromeOS we build the kernel with sample profiles by adding -fprofile-sample-use=/path/to/gcov.profile to KCFLAGS.
Quoted 7 lines
Quoted 4 lines
SHT_RELis generated by the latest lld, see
https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086.Is this part of a released toolchain? If so, can you spell out the first version where this occurs?
Yes, it was added in llvm-13. I will update the patch.
Quoted 6 lines
Quoted 3 lines
Disable profile optimization in kvm/nvhe to fix the build with AutoFDO.
It'd be good to at least mention how AutoFDO and -fprofile-sample-use relate to each other.
Good point. AutoFDO is an example of sample profiles. It's not actually relevant for the bug. I will better remove it.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Denis Nikitin <[email protected]>--- arch/arm64/kvm/hyp/nvhe/Makefile | 3 +++ 1 file changed, 3 insertions(+)Quoted 13 lines
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 93
Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/Makefile +2
-0@@ -89,6 +89,9 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +# Profile optimization creates SHT_REL section '.llvm.call-graph-profile' for +# the hot code. SHT_REL is currently not supported by the KVM tools.'KVM tools' seems vague. Maybe call out the actual helper that processes the relocations?
Agreed.
Quoted 3 lines
Quoted 2 lines
arch/arm64/kvm/hyp/nvhe/Makefile +1
-0+KBUILD_CFLAGS += $(call cc-option,-fno-profile-sample-use,-fno-profile-use)
Quoted 7 lines
Quoted 2 lines
Why adding these options instead of filtering out the offending option as it is done just above?
That was actually the alternative solution and it worked as well. Let me double check if profile optimization doesn't mess up with other sections and if it doesn't I will remove the '.llvm.call-graph-profile' section instead.
When I remove the '.llvm.call-graph-profile' section the layout of other sections slightly changes (offsets and sizes) compared to -fno-profile-sample-use. But the list of sections remains the same.
Quoted 7 lines
Quoted 4 lines
Also, is this the only place the kernel fails to compile? The EFI stub does similar things AFAIR, and could potentially fail the same way.
This was the only place in 5.15 where we tested it. Let me see if EFI has this section.
EFI code is not marked as hot in the profile.
Regarding "could potentially fail", I don't see any explicit manipulations with code sections in EFI.
The hardcoded EFI stub entries should not be affected.
Quoted 11 lines
Quoted 8 lines
Thanks,
M.--
Without deviation from the norm, progress is not possible.Thanks,
Denis
- Denis
Marc Zyngier
maintainerQuoted 76 lines · Denis Nikitin
Adding a few more comments...
Quoted 72 lines · Denis Nikitin
Hi Mark,
Thank you for a quick response.
Quoted 6 lines · Marc Zyngier
Hi Denis,
Quoted 1 line · Denis Nikitin
Quoted 7 lines
Quoted 4 lines
Kernel build with -fprofile-sample-use raises the following failure:
error:
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: UnexpectedSHT_RELsection ".rel.llvm.call-graph-profile"How is this flag provided? I don't see any occurrence of it in the kernel so far.
On ChromeOS we build the kernel with sample profiles by adding -fprofile-sample-use=/path/to/gcov.profile to KCFLAGS.
Quoted 7 lines
Quoted 4 lines
SHT_RELis generated by the latest lld, see
https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086.Is this part of a released toolchain? If so, can you spell out the first version where this occurs?
Yes, it was added in llvm-13. I will update the patch.
Quoted 6 lines
Quoted 3 lines
Disable profile optimization in kvm/nvhe to fix the build with AutoFDO.
It'd be good to at least mention how AutoFDO and -fprofile-sample-use relate to each other.
Good point. AutoFDO is an example of sample profiles. It's not actually relevant for the bug. I will better remove it.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Denis Nikitin <[email protected]>--- arch/arm64/kvm/hyp/nvhe/Makefile | 3 +++ 1 file changed, 3 insertions(+)Quoted 13 lines
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 93
Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/Makefile +2
-0@@ -89,6 +89,9 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +# Profile optimization creates SHT_REL section '.llvm.call-graph-profile' for +# the hot code. SHT_REL is currently not supported by the KVM tools.'KVM tools' seems vague. Maybe call out the actual helper that processes the relocations?
Agreed.
Quoted 5 lines
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 94
Quoted 2 lines
arch/arm64/kvm/hyp/nvhe/Makefile +1
-0+KBUILD_CFLAGS += $(call cc-option,-fno-profile-sample-use,-fno-profile-use)Why adding these options instead of filtering out the offending option as it is done just above?
Quoted 8 lines
Quoted 4 lines
That was actually the alternative solution and it worked as well. Let me double check if profile optimization doesn't mess up with other sections and if it doesn't I will remove the '.llvm.call-graph-profile' section instead.
When I remove the '.llvm.call-graph-profile' section the layout of other sections slightly changes (offsets and sizes) compared to
-fno-profile-sample-use. But the list of sections remains the same.
If this method works well enough, I'd rather we stick to it, instead of having two ways to disable this sort of things.
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
Also, is this the only place the kernel fails to compile? The EFI stub does similar things AFAIR, and could potentially fail the same way.
This was the only place in 5.15 where we tested it. Let me see if EFI has this section.
EFI code is not marked as hot in the profile.
Regarding "could potentially fail", I don't see any explicit manipulations with code sections in EFI.
The hardcoded EFI stub entries should not be affected.
I was more worried by the runtime relocation that the EFI stub performs for the kernel, but if you've checked that already, that works for me.
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v2 1/1 KVM: arm64: nvhe: Fix build with profile optimization
In reply to Denis NikitinKernel build with clang and KCFLAGS=-fprofile-sample-use fails with:
error: arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: Unexpected SHT_REL section ".rel.llvm.call-graph-profile"
Starting from 13.0.0 llvm can generate SHT_REL section, see
https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086.
gen-hyprel does not support SHT_REL relocation section.
Remove ".llvm.call-graph-profile" SHT_REL relocation from kvm_nvhe to fix the build.
---
V1 -> V2: Remove the relocation instead of disabling the profile-use flags.
--- arch/arm64/kvm/hyp/nvhe/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/Makefile +3 -1
@@ -78,8 +78,10 @@ $(obj)/kvm_nvhe.o: $(obj)/kvm_nvhe.rel.o FORCE # The HYPREL command calls `gen-hyprel` to generate an assembly file with # a list of relocations targeting hyp code/data. +# Starting from 13.0.0 llvm emits SHT_REL section '.llvm.call-graph-profile' +# when profile optimization is applied. gen-hyprel does not support SHT_REL. quiet_cmd_hyprel = HYPREL $@ - cmd_hyprel = $(obj)/gen-hyprel $< > $@ + cmd_hyprel = $(OBJCOPY) -R .llvm.call-graph-profile $<; $(obj)/gen-hyprel $< > $@ # The HYPCOPY command uses `objcopy` to prefix all ELF symbol names # to avoid clashes with VHE code/data.
Signature · 1 line
2.37.3.968.ga6b4b080e4-goog
Marc Zyngier
maintainerRe: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Quoted 25 lines · Denis Nikitin
Kernel build with clang and KCFLAGS=-fprofile-sample-use fails with:
error:
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: UnexpectedSHT_RELsection ".rel.llvm.call-graph-profile"Starting from 13.0.0 llvm can generate
SHT_RELsection, see
https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086.
gen-hyprel does not supportSHT_RELrelocation section.Remove ".llvm.call-graph-profile"
SHT_RELrelocation fromkvm_nvheto fix the build.Signed-off-by Denis Nikitin <[email protected]>---
V1 -> V2: Remove the relocation instead of disabling the profile-use flags.--- arch/arm64/kvm/hyp/nvhe/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm64/kvm/hyp/nvhe/Makefile +0
-0
arch/arm64/kvm/hyp/nvhe/Makefile $(obj)/kvm_nvhe.o: $(obj)/kvm_nvhe.rel.o FORCE · line 84
Quoted 8 lines
arch/arm64/kvm/hyp/nvhe/Makefile +3
-1@@ -78,8 +78,10 @@ $(obj)/kvm_nvhe.o: $(obj)/kvm_nvhe.rel.o FORCE # The HYPREL command calls `gen-hyprel` to generate an assembly file with # a list of relocations targeting hyp code/data. +# Starting from 13.0.0 llvm emits SHT_REL section '.llvm.call-graph-profile' +# when profile optimization is applied. gen-hyprel does not support SHT_REL. quiet_cmd_hyprel = HYPREL $@ - cmd_hyprel = $(obj)/gen-hyprel $< > $@ + cmd_hyprel = $(OBJCOPY) -R .llvm.call-graph-profile $<; $(obj)/gen-hyprel $< > $@
I was really hoping that you'd just drop the flags from the CFLAGS instead of removing the generated section. Something like:
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -88,7 +88,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. -KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI) -fprofile-sample-use, $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
However, I even failed to reproduce your problem using LLVM 14 as packaged by Debian (if that matters, I'm using an arm64 build machine). I build the kernel with:
$ make LLVM=1 KCFLAGS=-fprofile-sample-use -j8 vmlinux
and the offending object only contains the following sections:
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: file format elf64-littleaarch64
Sections:
Idx Name Size VMA LMA File off Algn
0 .hyp.idmap.text 00000ae4 0000000000000000 0000000000000000 00000800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .hyp.text 0000e988 0000000000000000 0000000000000000 00001800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .hyp.data..ro_after_init 00000820 0000000000000000 0000000000000000 00010188 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .hyp.rodata 00002e70 0000000000000000 0000000000000000 000109a8 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
4 .hyp.data..percpu 00001ee0 0000000000000000 0000000000000000 00013820 2**4
CONTENTS, ALLOC, LOAD, DATA
5 .hyp.bss 00001158 0000000000000000 0000000000000000 00015700 2**3
ALLOC
6 .comment 0000001f 0000000000000000 0000000000000000 00017830 2**0
CONTENTS, READONLY
7 .llvm_addrsig 000000b8 0000000000000000 0000000000000000 0001784f 2**0
CONTENTS, READONLY, EXCLUDE
8 .altinstructions 00001284 0000000000000000 0000000000000000 00015700 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
9 __jump_table 00000960 0000000000000000 0000000000000000 00016988 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
10 __bug_table 0000051c 0000000000000000 0000000000000000 000172e8 2**2
CONTENTS, ALLOC, LOAD, RELOC, DATA
11 __kvm_ex_table 00000028 0000000000000000 0000000000000000 00017808 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
12 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00027370 2**0
CONTENTS, READONLY
So what am I missing to trigger this issue? Does it rely on something like PGO, which is not upstream yet? A bit of handholding would be much appreciated.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Hi Mark,
Quoted 9 lines · Marc Zyngier
I was really hoping that you'd just drop the flags from the CFLAGS instead of removing the generated section. Something like:
arch/arm64/kvm/hyp/nvhe/Makefile +0
-0
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 94
Quoted 8 lines
arch/arm64/kvm/hyp/nvhe/Makefile +1
-1@@ -88,7 +88,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. -KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI) -fprofile-sample-use, $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
Sorry, I moved on with a different approach and didn't explain the rationale.
Like you mentioned before, the flag -fprofile-sample-use does not appear in the kernel. And it looks confusing when the flag is disabled or filtered out here. This was the first reason.
The root cause of the build failure wasn't the compiler profile guided optimization but the extra metadata in SHT_REL section which llvm injected into kvm_nvhe.tmp.o for further link optimization.
If we remove the .llvm.call-graph-profile section we fix the build and avoid potential problems with relocations optimized by the linker. The profile guided optimization will still be applied by the compiler.
Let me know what you think about it.
Quoted 40 lines
However, I even failed to reproduce your problem using LLVM 14 as packaged by Debian (if that matters, I'm using an arm64 build machine). I build the kernel with:
$ make LLVM=1 KCFLAGS=-fprofile-sample-use -j8 vmlinuxand the offending object only contains the following sections:
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: file format elf64-littleaarch64Sections:
Idx Name Size VMA LMA File off Algn
0 .hyp.idmap.text00000ae40000000000000000 0000000000000000 00000800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .hyp.text0000e9880000000000000000 0000000000000000 00001800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .hyp.data..ro_after_init 00000820 0000000000000000 0000000000000000 00010188 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .hyp.rodata00002e700000000000000000 0000000000000000000109a82**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
4 .hyp.data..percpu00001ee00000000000000000 0000000000000000 00013820 2**4
CONTENTS, ALLOC, LOAD, DATA
5 .hyp.bss 00001158 0000000000000000 0000000000000000 00015700 2**3
ALLOC
6 .comment0000001f0000000000000000 0000000000000000 00017830 2**0
CONTENTS, READONLY
7 .llvm_addrsig000000b80000000000000000 00000000000000000001784f2**0
CONTENTS, READONLY, EXCLUDE
8 .altinstructions 00001284 0000000000000000 0000000000000000 00015700 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
9__jump_table00000960 0000000000000000 0000000000000000 00016988 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
10__bug_table0000051c0000000000000000 0000000000000000000172e82**2
CONTENTS, ALLOC, LOAD, RELOC, DATA
11__kvm_ex_table00000028 0000000000000000 0000000000000000 00017808 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
12 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00027370 2**0
CONTENTS, READONLY
Quoted 3 lines
So what am I missing to trigger this issue? Does it rely on something like PGO, which is not upstream yet? A bit of handholding would be much appreciated.
Right, it relies on the PGO profile.
On ChromeOS we collect the sample PGO profile from Arm devices with enabled CoreSight/ETM. You can find more details on ETM at
https://www.kernel.org/doc/Documentation/trace/coresight/coresight.rst.
https://github.com/Linaro/OpenCSD/blob/master/decoder/tests/auto-fdo/autofdo.md
contains information about the pipeline of collecting, processing, and applying the profile.
Quoted 7 lines
Thanks,
M.--
Without deviation from the norm, progress is not possible.
Thanks,
Denis
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Quoted 43 lines · Denis Nikitin
Hi Mark,
Review
Quoted 5 lines · Marc Zyngier
I was really hoping that you'd just drop the flags from the CFLAGS instead of removing the generated section. Something like:
(quoted diff) +0
-0b/arch/arm64/kvm/hyp/nvhe/Makefile
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 90
Quoted 7 lines
index
b5c5119c7396..e5b2d43925b4100644arch/arm64/kvm/hyp/nvhe/Makefile +0
-0@@ -88,7 +88,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi'annotations.
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 91
Quoted 1 line
arch/arm64/kvm/hyp/nvhe/Makefile +0
-1-KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)$(CC_FLAGS_CFI), $(KBUILD_CFLAGS))
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 91
Quoted 1 line
arch/arm64/kvm/hyp/nvhe/Makefile +1
-0+KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)$(CC_FLAGS_CFI) -fprofile-sample-use, $(KBUILD_CFLAGS))
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 92
Quoted 2 lines
arch/arm64/kvm/hyp/nvhe/Makefile +0
-0# KVM nVHE code is run at a different exception code with a differentmap, so
arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 93
Quoted 1 line
arch/arm64/kvm/hyp/nvhe/Makefile +0
-0# compiler instrumentation that inserts callbacks or checks into thecode may
Sorry, I moved on with a different approach and didn't explain the rationale.
Like you mentioned before, the flag
-fprofile-sample-usedoes not appear in the kernel. And it looks confusing when the flag is disabled or filtered out
here. This was the first reason.The root cause of the build failure wasn't the compiler profile guided optimization but the extra metadata in
SHT_RELsection which llvm injected into kvm_nvhe.tmp.o for further link optimization.
If we remove the .llvm.call-graph-profile section we fix the build and avoid
potential problems with relocations optimized by the linker. The profile guided optimization will still be applied by the compiler.
Quoted 12 lines
Let me know what you think about it.
Quoted 9 lines
However, I even failed to reproduce your problem using LLVM 14 as packaged by Debian (if that matters, I'm using an arm64 build machine). I build the kernel with:
$ make LLVM=1 KCFLAGS=-fprofile-sample-use -j8 vmlinuxand the offending object only contains the following sections:
Just some comments based on my ChromeOS build experience.
fprofile-sample-use needs the profile file name argument to read the pgo data from
i.e. -fprofile-sample-use=/path/to/gcov.profile.
Since the path to filename can change, it makes filtering out more difficult.
It is certainly possible to find and filter the exact argument by some string search of KCFLAGS.
But passing -fno-profile-sample-use is easier and less error prone which I believe the previous patch version tried to do.
Quoted 56 lines
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: file format
elf64-littleaarch64Quoted 3 lines
Sections:
Idx Name Size VMA LMA Fileoff Algn
Quoted 1 line
0 .hyp.idmap.text
00000ae40000000000000000 000000000000000000000800 2**11
Quoted 2 lines
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .hyp.text0000e9880000000000000000 000000000000000000001800 2**11
Quoted 2 lines
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .hyp.data..ro_after_init 00000820 00000000000000000000000000000000 00010188 2**3
Quoted 2 lines
CONTENTS, ALLOC, LOAD, DATA
3 .hyp.rodata00002e700000000000000000 0000000000000000
000109a82**3Quoted 2 lines
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
4 .hyp.data..percpu00001ee00000000000000000 000000000000000000013820 2**4
Quoted 2 lines
CONTENTS, ALLOC, LOAD, DATA
5 .hyp.bss 00001158 0000000000000000 000000000000000000015700 2**3
Quoted 2 lines
ALLOC
6 .comment0000001f0000000000000000 000000000000000000017830 2**0
Quoted 2 lines
CONTENTS, READONLY
7 .llvm_addrsig000000b80000000000000000 0000000000000000
0001784f2**0Quoted 2 lines
CONTENTS, READONLY, EXCLUDE
8 .altinstructions 00001284 0000000000000000 000000000000000000015700 2**0
Quoted 2 lines
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
9__jump_table00000960 0000000000000000 000000000000000000016988 2**3
Quoted 2 lines
CONTENTS, ALLOC, LOAD, RELOC, DATA
10__bug_table0000051c0000000000000000 0000000000000000
000172e82**2Quoted 2 lines
CONTENTS, ALLOC, LOAD, RELOC, DATA
11__kvm_ex_table00000028 0000000000000000 000000000000000000017808 2**3
Quoted 2 lines
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
12 .note.GNU-stack 00000000 0000000000000000 000000000000000000027370 2**0
Quoted 5 lines
CONTENTS, READONLY
So what am I missing to trigger this issue? Does it rely on something like PGO, which is not upstream yet? A bit of handholding would be much appreciated.
Right, it relies on the PGO profile.
On ChromeOS we collect the sample PGO profile from Arm devices with enabled CoreSight/ETM. You can find more details on ETM at
https://www.kernel.org/doc/Documentation/trace/coresight/coresight.rst.
Quoted 6 lines
https://github.com/Linaro/OpenCSD/blob/master/decoder/tests/auto-fdo/autofdo.md
contains information about the pipeline of collecting, processing, and applying
the profile.
Generally the difficult part is in collecting a good matching profile for the workload.
So I think this patch is better than previous since it still keeps the compiler optimization for the hot code paths
in the file but removes the problematic section.
Thanks,
Manoj
Quoted 11 lines
Quoted 7 lines
Thanks,
M.--
Without deviation from the norm, progress is not possible.Thanks,
Denis
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Hi Marc,
Please let me know what you think about this approach.
Thanks,
Denis
Quoted 107 lines · Manoj Gupta
Quoted 28 lines · Denis Nikitin
Hi Mark,
Quoted 9 lines · Marc Zyngier
I was really hoping that you'd just drop the flags from the CFLAGS instead of removing the generated section. Something like:
arch/arm64/kvm/hyp/nvhe/Makefile +0
-0arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 94
Quoted 8 lines
arch/arm64/kvm/hyp/nvhe/Makefile +1
-1@@ -88,7 +88,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. -KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI) -fprofile-sample-use, $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code maySorry, I moved on with a different approach and didn't explain the rationale.
Like you mentioned before, the flag
-fprofile-sample-usedoes not appear in the kernel. And it looks confusing when the flag is disabled or filtered out here. This was the first reason.Quoted 18 lines
The root cause of the build failure wasn't the compiler profile guided optimization but the extra metadata in
SHT_RELsection which llvm injected into kvm_nvhe.tmp.o for further link optimization.
If we remove the .llvm.call-graph-profile section we fix the build and avoid potential problems with relocations optimized by the linker. The profile guided optimization will still be applied by the compiler.Let me know what you think about it.
Quoted 9 lines
However, I even failed to reproduce your problem using LLVM 14 as packaged by Debian (if that matters, I'm using an arm64 build machine). I build the kernel with:
$ make LLVM=1 KCFLAGS=-fprofile-sample-use -j8 vmlinuxand the offending object only contains the following sections:
Just some comments based on my ChromeOS build experience.
fprofile-sample-use needs the profile file name argument to read the pgo data from i.e. -fprofile-sample-use=/path/to/gcov.profile.
Since the path to filename can change, it makes filtering out more difficult.
It is certainly possible to find and filter the exact argument by some string search of KCFLAGS.
But passing -fno-profile-sample-use is easier and less error prone which I believe the previous patch version tried to do.Quoted 35 lines
Quoted 31 lines
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: file format elf64-littleaarch64Sections:
Idx Name Size VMA LMA File off Algn
0 .hyp.idmap.text00000ae40000000000000000 0000000000000000 00000800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .hyp.text0000e9880000000000000000 0000000000000000 00001800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .hyp.data..ro_after_init 00000820 0000000000000000 0000000000000000 00010188 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .hyp.rodata00002e700000000000000000 0000000000000000000109a82**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
4 .hyp.data..percpu00001ee00000000000000000 0000000000000000 00013820 2**4
CONTENTS, ALLOC, LOAD, DATA
5 .hyp.bss 00001158 0000000000000000 0000000000000000 00015700 2**3
ALLOC
6 .comment0000001f0000000000000000 0000000000000000 00017830 2**0
CONTENTS, READONLY
7 .llvm_addrsig000000b80000000000000000 00000000000000000001784f2**0
CONTENTS, READONLY, EXCLUDE
8 .altinstructions 00001284 0000000000000000 0000000000000000 00015700 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
9__jump_table00000960 0000000000000000 0000000000000000 00016988 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
10__bug_table0000051c0000000000000000 0000000000000000000172e82**2
CONTENTS, ALLOC, LOAD, RELOC, DATA
11__kvm_ex_table00000028 0000000000000000 0000000000000000 00017808 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
12 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00027370 2**0
CONTENTS, READONLYQuoted 3 lines
So what am I missing to trigger this issue? Does it rely on something like PGO, which is not upstream yet? A bit of handholding would be much appreciated.
Quoted 9 lines
Right, it relies on the PGO profile.
On ChromeOS we collect the sample PGO profile from Arm devices with enabled CoreSight/ETM. You can find more details on ETM at
https://www.kernel.org/doc/Documentation/trace/coresight/coresight.rst.https://github.com/Linaro/OpenCSD/blob/master/decoder/tests/auto-fdo/autofdo.md
contains information about the pipeline of collecting, processing, and applying the profile.
Quoted 19 lines
Generally the difficult part is in collecting a good matching profile for the workload.
So I think this patch is better than previous since it still keeps the compiler optimization for the hot code paths in the file but removes the problematic section.Thanks,
ManojQuoted 11 lines
Quoted 8 lines
Thanks,
M.--
Without deviation from the norm, progress is not possible.Thanks,
Denis
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Hi Mark,
This problem currently blocks the PGO roll on the ChromeOS kernel and we need some kind of a solution.
Could you please take a look?
Thanks,
Denis
Quoted 135 lines · Denis Nikitin
Hi Marc,
Please let me know what you think about this approach.
Thanks,
DenisQuoted 126 lines · Manoj Gupta
Quoted 28 lines · Denis Nikitin
Hi Mark,
Quoted 9 lines · Marc Zyngier
I was really hoping that you'd just drop the flags from the CFLAGS instead of removing the generated section. Something like:
arch/arm64/kvm/hyp/nvhe/Makefile +0
-0arch/arm64/kvm/hyp/nvhe/Makefile quiet_cmd_hypcopy = HYPCOPY $@ · line 94
Quoted 8 lines
arch/arm64/kvm/hyp/nvhe/Makefile +1
-1@@ -88,7 +88,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. -KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI) -fprofile-sample-use, $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code maySorry, I moved on with a different approach and didn't explain the rationale.
Like you mentioned before, the flag
-fprofile-sample-usedoes not appear in the kernel. And it looks confusing when the flag is disabled or filtered out here. This was the first reason.Quoted 18 lines
The root cause of the build failure wasn't the compiler profile guided optimization but the extra metadata in
SHT_RELsection which llvm injected into kvm_nvhe.tmp.o for further link optimization.
If we remove the .llvm.call-graph-profile section we fix the build and avoid potential problems with relocations optimized by the linker. The profile guided optimization will still be applied by the compiler.Let me know what you think about it.
Quoted 9 lines
However, I even failed to reproduce your problem using LLVM 14 as packaged by Debian (if that matters, I'm using an arm64 build machine). I build the kernel with:
$ make LLVM=1 KCFLAGS=-fprofile-sample-use -j8 vmlinuxand the offending object only contains the following sections:
Just some comments based on my ChromeOS build experience.
fprofile-sample-use needs the profile file name argument to read the pgo data from i.e. -fprofile-sample-use=/path/to/gcov.profile.
Since the path to filename can change, it makes filtering out more difficult.
It is certainly possible to find and filter the exact argument by some string search of KCFLAGS.
But passing -fno-profile-sample-use is easier and less error prone which I believe the previous patch version tried to do.Quoted 35 lines
Quoted 31 lines
arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: file format elf64-littleaarch64Sections:
Idx Name Size VMA LMA File off Algn
0 .hyp.idmap.text00000ae40000000000000000 0000000000000000 00000800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .hyp.text0000e9880000000000000000 0000000000000000 00001800 2**11
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .hyp.data..ro_after_init 00000820 0000000000000000 0000000000000000 00010188 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .hyp.rodata00002e700000000000000000 0000000000000000000109a82**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
4 .hyp.data..percpu00001ee00000000000000000 0000000000000000 00013820 2**4
CONTENTS, ALLOC, LOAD, DATA
5 .hyp.bss 00001158 0000000000000000 0000000000000000 00015700 2**3
ALLOC
6 .comment0000001f0000000000000000 0000000000000000 00017830 2**0
CONTENTS, READONLY
7 .llvm_addrsig000000b80000000000000000 00000000000000000001784f2**0
CONTENTS, READONLY, EXCLUDE
8 .altinstructions 00001284 0000000000000000 0000000000000000 00015700 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
9__jump_table00000960 0000000000000000 0000000000000000 00016988 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
10__bug_table0000051c0000000000000000 0000000000000000000172e82**2
CONTENTS, ALLOC, LOAD, RELOC, DATA
11__kvm_ex_table00000028 0000000000000000 0000000000000000 00017808 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
12 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00027370 2**0
CONTENTS, READONLYQuoted 3 lines
So what am I missing to trigger this issue? Does it rely on something like PGO, which is not upstream yet? A bit of handholding would be much appreciated.
Quoted 9 lines
Right, it relies on the PGO profile.
On ChromeOS we collect the sample PGO profile from Arm devices with enabled CoreSight/ETM. You can find more details on ETM at
https://www.kernel.org/doc/Documentation/trace/coresight/coresight.rst.https://github.com/Linaro/OpenCSD/blob/master/decoder/tests/auto-fdo/autofdo.md
contains information about the pipeline of collecting, processing, and applying the profile.Generally the difficult part is in collecting a good matching profile for the workload.
So I think this patch is better than previous since it still keeps the compiler optimization for the hot code paths in the file but removes the problematic section.Thanks,
ManojQuoted 11 lines
Quoted 8 lines
Thanks,
M.--
Without deviation from the norm, progress is not possible.Thanks,
Denis
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerRe: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Quoted 2 lines · Denis Nikitin
Hi Mark,
s/k/c/
Quoted 3 lines
This problem currently blocks the PGO roll on the ChromeOS kernel and we need some kind of a solution.
I'm sorry, but I don't feel constrained by your internal deadlines. I have my own...
Quoted 1 line
Could you please take a look?
I have asked for a reproducer. All I got for an answer is "this is hard". Providing a profiling file would help, for example.
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Quoted 12 lines · Marc Zyngier
Quoted 2 lines · Denis Nikitin
Hi Mark,
s/k/c/
Quoted 3 lines
This problem currently blocks the PGO roll on the ChromeOS kernel and we need some kind of a solution.
Quoted 7 lines
I'm sorry, but I don't feel constrained by your internal deadlines. I have my own...
Quoted 1 line
Could you please take a look?
I have asked for a reproducer. All I got for an answer is "this is hard". Providing a profiling file would help, for example.
Could you please try the following profile on the 5.15 branch?
$ cat <<EOF > prof.txt
kvm_pgtable_walk:100:10
2: 5
3: 5
5: 5
6: 5
10: 5
10: _kvm_pgtable_walk:50
5: 5
7: 5
10: 5
13.2: 5
14: 5
16: 5 __kvm_pgtable_walk:5
13: kvm_pgd_page_idx:30
2: __kvm_pgd_page_idx:30
2: 5
3: 5
5: 5
2: kvm_granule_shift:5
3: 5
EOF$ make LLVM=1 ARCH=arm64 KCFLAGS=-fprofile-sample-use=prof.txt -j8 vmlinux
Thanks,
Denis
Quoted 5 lines
M.--
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerRe: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Quoted 47 lines · Denis Nikitin
Quoted 12 lines · Marc Zyngier
Quoted 2 lines · Denis Nikitin
Hi Mark,
s/k/c/
Quoted 3 lines
This problem currently blocks the PGO roll on the ChromeOS kernel and we need some kind of a solution.
Quoted 7 lines
I'm sorry, but I don't feel constrained by your internal deadlines. I have my own...
Quoted 1 line
Could you please take a look?
I have asked for a reproducer. All I got for an answer is "this is hard". Providing a profiling file would help, for example.
Could you please try the following profile on the 5.15 branch?
$ cat <<EOF > prof.txt kvm_pgtable_walk:100:10 2: 5 3: 5 5: 5 6: 5 10: 5 10: _kvm_pgtable_walk:50 5: 5 7: 5 10: 5 13.2: 5 14: 5 16: 5 __kvm_pgtable_walk:5 13: kvm_pgd_page_idx:30 2: __kvm_pgd_page_idx:30 2: 5 3: 5 5: 5 2: kvm_granule_shift:5 3: 5 EOF
Quoted 1 line
$ make LLVM=1 ARCH=arm64 KCFLAGS=-fprofile-sample-use=prof.txt -j8 vmlinux
Thanks, this was helpful, as I was able to reproduce the build failure.
FWIW, it seems pretty easy to work around by filtering out the offending option, making it consistent with the mechanism we already use for tracing and the like.
I came up with the hack below, which does the trick and is IMHO better than dropping the section (extra work) or adding the negation of this option (which depends on the compiler option evaluation order).
M.
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -91,7 +91,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. -KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI) -fprofile-sample-use=%, $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization
Thank you Marc for figuring out the filtering-out solution! It fixed the build on ChromeOS.
I will update the patch and also filter out -fprofile-use which will avoid a similar problem with the instrumented PGO in the future.
Thanks,
Denis
Quoted 80 lines · Marc Zyngier
Quoted 47 lines · Denis Nikitin
Quoted 12 lines · Marc Zyngier
Quoted 2 lines · Denis Nikitin
Hi Mark,
s/k/c/
Quoted 3 lines
This problem currently blocks the PGO roll on the ChromeOS kernel and we need some kind of a solution.
Quoted 7 lines
I'm sorry, but I don't feel constrained by your internal deadlines. I have my own...
Quoted 1 line
Could you please take a look?
I have asked for a reproducer. All I got for an answer is "this is hard". Providing a profiling file would help, for example.
Could you please try the following profile on the 5.15 branch?
$ cat <<EOF > prof.txt kvm_pgtable_walk:100:10 2: 5 3: 5 5: 5 6: 5 10: 5 10: _kvm_pgtable_walk:50 5: 5 7: 5 10: 5 13.2: 5 14: 5 16: 5 __kvm_pgtable_walk:5 13: kvm_pgd_page_idx:30 2: __kvm_pgd_page_idx:30 2: 5 3: 5 5: 5 2: kvm_granule_shift:5 3: 5 EOFQuoted 1 line
$ make LLVM=1 ARCH=arm64 KCFLAGS=-fprofile-sample-use=prof.txt -j8 vmlinuxThanks, this was helpful, as I was able to reproduce the build failure.
FWIW, it seems pretty easy to work around by filtering out the offending option, making it consistent with the mechanism we already use for tracing and the like.
I came up with the hack below, which does the trick and is IMHO better than dropping the section (extra work) or adding the negation of this option (which depends on the compiler option evaluation order).
M.arch/arm64/kvm/hyp/nvhe/Makefile +1
-2@@ -91,7 +91,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. -KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI) -fprofile-sample-use=%, $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may --
Quoted 1 line
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm