trace: Make FTRACE_MCOUNT_USE_RECORDMCOUNT configurable
RFC PATCH 1/1 trace: Make FTRACE_MCOUNT_USE_RECORDMCOUNT configurable
For whatever reason LLVM does not allow LTO (Link Time Optimization) if FTRACE_MCOUNT_USE_RECORDMCOUNT is enabled.
This allows disabling just this option instead of disabling all FTRACE options.
---
Or disabling FTRACE is the right thing to do if HAS_LTO_CLANG=y?
Came from arch/Kconfig:
config HAS_LTO_CLANG
def_bool y
depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM
depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm)
depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm)
depends on ARCH_SUPPORTS_LTO_CLANG
depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT <======
depends on !KASAN || KASAN_HW_TAGS
depends on !GCOV_KERNEL--- kernel/trace/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/Kconfig +2 -1
@@ -704,7 +704,8 @@ config FTRACE_MCOUNT_USE_OBJTOOL depends on FTRACE_MCOUNT_RECORD config FTRACE_MCOUNT_USE_RECORDMCOUNT - def_bool y + bool "Enable FTRACE_MCOUNT_USE_RECORDMCOUNT" + default y depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_CC depends on !FTRACE_MCOUNT_USE_OBJTOOL
Signature · 1 line
2.30.2
+ Sami, Kees
Do you guys remember why we don't supportFTRACE_MCOUNT_USE_RECORDMCOUNT with LTO?
https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/?
Quoted 46 lines · Alexey Kardashevskiy
For whatever reason LLVM does not allow LTO (Link Time Optimization) if
FTRACE_MCOUNT_USE_RECORDMCOUNTis enabled.This allows disabling just this option instead of disabling all FTRACE options.
Signed-off-by Alexey Kardashevskiy <[email protected]>---
Or disabling FTRACE is the right thing to do if HAS_LTO_CLANG=y?
Came from
arch/Kconfig:config
HAS_LTO_CLANGdef_bool y depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT <====== depends on !KASAN || KASAN_HW_TAGS depends on !GCOV_KERNEL--- kernel/trace/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/trace/Kconfig +2
-2@@ -704,7 +704,8 @@ config FTRACE_MCOUNT_USE_OBJTOOL depends on FTRACE_MCOUNT_RECORD config FTRACE_MCOUNT_USE_RECORDMCOUNT - def_bool y + bool "Enable FTRACE_MCOUNT_USE_RECORDMCOUNT" + default y depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_CC depends on !FTRACE_MCOUNT_USE_OBJTOOL --2.30.2
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 5 lines · Nick Desaulniers
+ Sami, Kees
Do you guys remember why we don't support
FTRACE_MCOUNT_USE_RECORDMCOUNTwith LTO?
It's because recordmcount cannot distinguish between calls and other references to mcount/fentry, which is a problem with LTO where we have to process the entire vmlinux.o and cannot ignore individual translation units. Instead of resorting to workarounds, Peter was kind enough to implement a smarter mcount pass in objtool, which we now use on x86_64 with LTO.
Alexey, which architecture are you trying to fix here?
Sami
Quoted 8 lines · Sami Tolvanen
Quoted 5 lines · Nick Desaulniers
+ Sami, Kees
Do you guys remember why we don't support
FTRACE_MCOUNT_USE_RECORDMCOUNTwith LTO?
Quoted 6 lines
It's because recordmcount cannot distinguish between calls and other references to mcount/fentry, which is a problem with LTO where we have to process the entire vmlinux.o and cannot ignore individual translation units. Instead of resorting to workarounds, Peter was kind enough to implement a smarter mcount pass in objtool, which we now use on
x86_64with LTO.
So can x86_64 have both FTRACE_MCOUNT_USE_RECORDMCOUNT and LTO?
Quoted 1 line
Alexey, which architecture are you trying to fix here?
powerpc64le.
Quoted 2 lines
Sami
Quoted 11 lines · Alexey Kardashevskiy
Quoted 8 lines · Sami Tolvanen
Quoted 5 lines · Nick Desaulniers
+ Sami, Kees
Do you guys remember why we don't support
FTRACE_MCOUNT_USE_RECORDMCOUNTwith LTO?
Quoted 6 lines
Quoted 6 lines
It's because recordmcount cannot distinguish between calls and other references to mcount/fentry, which is a problem with LTO where we have to process the entire vmlinux.o and cannot ignore individual translation units. Instead of resorting to workarounds, Peter was kind enough to implement a smarter mcount pass in objtool, which we now use on
x86_64with LTO.
I had responded on a different thread about this:
http://lkml.kernel.org/r/[email protected]
We are working on enabling 'objtool check --mcount' on powerpc.
Quoted 3 lines
So can
x86_64have bothFTRACE_MCOUNT_USE_RECORDMCOUNTand LTO?
No. x86_64 now supports HAVE_OBJTOOL_MCOUNT, which enables FTRACE_MCOUNT_USE_OBJTOOL. That allows LTO to be used.
- Naveen
Steven Rostedt
maintainerQuoted 5 lines · On Fri, 11 Feb 2022 12:43:13 +1100 Alexey Kardashevskiy <[email protected]> wrote:
For whatever reason LLVM does not allow LTO (Link Time Optimization) if
FTRACE_MCOUNT_USE_RECORDMCOUNTis enabled.This allows disabling just this option instead of disabling all FTRACE options.
What FTRACE options are you talking about?
Quoted 28 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
Or disabling FTRACE is the right thing to do if HAS_LTO_CLANG=y?
Came from
arch/Kconfig:config
HAS_LTO_CLANGdef_bool y depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT <====== depends on !KASAN || KASAN_HW_TAGS depends on !GCOV_KERNEL--- kernel/trace/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/trace/Kconfig +0
-0
kernel/trace/Kconfig config FTRACE_MCOUNT_USE_OBJTOOL · line 708
Quoted 6 lines
kernel/trace/Kconfig +2
-1@@ -704,7 +704,8 @@ config FTRACE_MCOUNT_USE_OBJTOOL depends on FTRACE_MCOUNT_RECORD config FTRACE_MCOUNT_USE_RECORDMCOUNT - def_bool y + bool "Enable FTRACE_MCOUNT_USE_RECORDMCOUNT" + default y
I don't think this does what you think it does.
This is not something that should be user selectable. What exactly are you trying to accomplish here?
-- Steve
Quoted 3 lines
kernel/trace/Kconfig +0
-0depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_CC depends on !FTRACE_MCOUNT_USE_OBJTOOL
Quoted 10 lines · Steven Rostedt
Quoted 5 lines · On Fri, 11 Feb 2022 12:43:13 +1100 Alexey Kardashevskiy <[email protected]> wrote:
For whatever reason LLVM does not allow LTO (Link Time Optimization) if
FTRACE_MCOUNT_USE_RECORDMCOUNTis enabled.This allows disabling just this option instead of disabling all FTRACE options.
What FTRACE options are you talking about?
LTO_CLANG_THIN => HAS_LTO_CLANG => !FTRACE_MCOUNT_USE_RECORDMCOUNT =>
FTRACE [=y] && !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY [=n] && !FTRACE_MCOUNT_USE_CC [=n] && !FTRACE_MCOUNT_USE_OBJTOOL [=n] && FTRACE_MCOUNT_RECORD [=y]
A bunch.
Quoted 31 lines
Quoted 31 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
Or disabling FTRACE is the right thing to do if HAS_LTO_CLANG=y?
Came from
arch/Kconfig:config
HAS_LTO_CLANGdef_bool y depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT <====== depends on !KASAN || KASAN_HW_TAGS depends on !GCOV_KERNEL--- kernel/trace/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/trace/Kconfig +0
-0@@ -704,7 +704,8 @@ config FTRACE_MCOUNT_USE_OBJTOOL depends on FTRACE_MCOUNT_RECORD
Quoted 6 lines
kernel/trace/Kconfig config FTRACE_MCOUNT_USE_OBJTOOL · line 708
Quoted 4 lines
kernel/trace/Kconfig +2
-1config FTRACE_MCOUNT_USE_RECORDMCOUNT - def_bool y + bool "Enable FTRACE_MCOUNT_USE_RECORDMCOUNT" + default yI don't think this does what you think it does.
Sounds like it.
Quoted 2 lines
This is not something that should be user selectable. What exactly are you trying to accomplish here?
I am trying to
arch/powerpc/Kconfig +2 -0
@@ -153,6 +153,8 @@ config PPC select ARCH_WANT_IRQS_OFF_ACTIVATE_MM select ARCH_WANT_LD_ORPHAN_WARN select ARCH_WEAK_RELEASE_ACQUIRE + select ARCH_SUPPORTS_LTO_CLANG if PPC64 + select ARCH_SUPPORTS_LTO_CLANG_THIN if PPC64
to get LTO working on powerpc64le with minimal change to ppc64le_defconfig which has all these FTRACE_xxx enabled.
Quoted 8 lines
-- Steve
Quoted 3 lines
kernel/trace/Kconfig +0
-0depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_CC depends on !FTRACE_MCOUNT_USE_OBJTOOL
Steven Rostedt
maintainerQuoted 10 lines · On Wed, 16 Feb 2022 12:19:14 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Fri, 11 Feb 2022 12:43:13 +1100 Alexey Kardashevskiy <[email protected]> wrote:
For whatever reason LLVM does not allow LTO (Link Time Optimization) if
FTRACE_MCOUNT_USE_RECORDMCOUNTis enabled.This allows disabling just this option instead of disabling all FTRACE options.
Quoted 7 lines
Quoted 1 line
What FTRACE options are you talking about?
LTO_CLANG_THIN=>HAS_LTO_CLANG=> !FTRACE_MCOUNT_USE_RECORDMCOUNT =>FTRACE [=y] && !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY [=n] && !FTRACE_MCOUNT_USE_CC [=n] && !FTRACE_MCOUNT_USE_OBJTOOL [=n] &&
FTRACE_MCOUNT_RECORD[=y]
So basically, turn off FUNCTION_TRACER and STACK_TRACER.
Quoted 61 lines
A bunch.
Quoted 31 lines
Quoted 31 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
Or disabling FTRACE is the right thing to do if HAS_LTO_CLANG=y?
Came from
arch/Kconfig:config
HAS_LTO_CLANGdef_bool y depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT <====== depends on !KASAN || KASAN_HW_TAGS depends on !GCOV_KERNEL--- kernel/trace/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/trace/Kconfig +0
-0@@ -704,7 +704,8 @@ config FTRACE_MCOUNT_USE_OBJTOOL depends on FTRACE_MCOUNT_RECORDQuoted 6 lines
kernel/trace/Kconfig config FTRACE_MCOUNT_USE_OBJTOOL · line 708
Quoted 4 lines
kernel/trace/Kconfig +2
-1config FTRACE_MCOUNT_USE_RECORDMCOUNT - def_bool y + bool "Enable FTRACE_MCOUNT_USE_RECORDMCOUNT" + default yI don't think this does what you think it does.
Sounds like it.
Quoted 2 lines
This is not something that should be user selectable. What exactly are you trying to accomplish here?
I am trying to
arch/powerpc/Kconfig +2
-0@@ -153,6 +153,8 @@ config PPC select ARCH_WANT_IRQS_OFF_ACTIVATE_MM select ARCH_WANT_LD_ORPHAN_WARN select ARCH_WEAK_RELEASE_ACQUIRE + select ARCH_SUPPORTS_LTO_CLANG if PPC64 + select ARCH_SUPPORTS_LTO_CLANG_THIN if PPC64
Quoted 2 lines
to get LTO working on powerpc64le with minimal change to
ppc64le_defconfigwhich has all theseFTRACE_xxxenabled.
Well, you can add a dependency against FUNCTION_TRACER. As that's what turns on the RECORD_MCOUNT, as RECORD_MCOUNT is needed by it.
-- Steve