tracing: Remove redundant config HAVE_FTRACE_MCOUNT_RECORD

Ftrace is tightly coupled with architecture specific code because it
requires the use of trampolines written in assembly. This means that when
a new feature or optimization is made, it must be done for all
architectures. To simplify the approach, CONFIG_HAVE_FTRACE_* configs are
added to denote which architecture has the new enhancement so that other
architectures can still function until they too have been updated.

The CONFIG_HAVE_FTRACE_MCOUNT was added to help simplify the
DYNAMIC_FTRACE work, but now every architecture that implements
DYNAMIC_FTRACE also has HAVE_FTRACE_MCOUNT set too, making it redundant
with the HAVE_DYNAMIC_FTRACE.

Remove the HAVE_FTRACE_MCOUNT config and use DYNAMIC_FTRACE directly where
applicable.

Link: https://lore.kernel.org/all/20250703154916.48e3ada7@gandalf.local.home/

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/20250704104838.27a18690@gandalf.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt
2025-07-04 10:48:38 -04:00
committed by Steven Rostedt (Google)
parent 9b4d5d330f
commit 4d6d0a6263
22 changed files with 16 additions and 47 deletions

View File

@@ -238,19 +238,15 @@ You need very few things to get the syscalls tracing in an arch.
- Tag this arch as HAVE_SYSCALL_TRACEPOINTS. - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
HAVE_FTRACE_MCOUNT_RECORD HAVE_DYNAMIC_FTRACE
------------------------- -------------------
See scripts/recordmcount.pl for more info. Just fill in the arch-specific See scripts/recordmcount.pl for more info. Just fill in the arch-specific
details for how to locate the addresses of mcount call sites via objdump. details for how to locate the addresses of mcount call sites via objdump.
This option doesn't make much sense without also implementing dynamic ftrace. This option doesn't make much sense without also implementing dynamic ftrace.
You will first need HAVE_FUNCTION_TRACER, so scroll your reader back up if you
HAVE_DYNAMIC_FTRACE got over eager.
-------------------
You will first need HAVE_FTRACE_MCOUNT_RECORD and HAVE_FUNCTION_TRACER, so
scroll your reader back up if you got over eager.
Once those are out of the way, you will need to implement: Once those are out of the way, you will need to implement:
- asm/ftrace.h: - asm/ftrace.h:

View File

@@ -107,7 +107,6 @@ config ARM
select HAVE_EFFICIENT_UNALIGNED_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && MMU select HAVE_EFFICIENT_UNALIGNED_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && MMU
select HAVE_EXIT_THREAD select HAVE_EXIT_THREAD
select HAVE_GUP_FAST if ARM_LPAE select HAVE_GUP_FAST if ARM_LPAE
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER if !XIP_KERNEL select HAVE_FUNCTION_TRACER if !XIP_KERNEL

View File

@@ -223,7 +223,6 @@ config ARM64
select HAVE_EFFICIENT_UNALIGNED_ACCESS select HAVE_EFFICIENT_UNALIGNED_ACCESS
select HAVE_GUP_FAST select HAVE_GUP_FAST
select HAVE_FTRACE_GRAPH_FUNC select HAVE_FTRACE_GRAPH_FUNC
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_FREGS select HAVE_FUNCTION_GRAPH_FREGS

View File

@@ -80,7 +80,6 @@ config CSKY
select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO select HAVE_KERNEL_LZO
select HAVE_KERNEL_LZMA select HAVE_KERNEL_LZMA

View File

@@ -144,7 +144,6 @@ config LOONGARCH
select HAVE_EXIT_THREAD select HAVE_EXIT_THREAD
select HAVE_GUP_FAST select HAVE_GUP_FAST
select HAVE_FTRACE_GRAPH_FUNC select HAVE_FTRACE_GRAPH_FUNC
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_FUNCTION_ARG_ACCESS_API
select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_FREGS select HAVE_FUNCTION_GRAPH_FREGS

View File

@@ -28,7 +28,6 @@ config MICROBLAZE
select HAVE_DEBUG_KMEMLEAK select HAVE_DEBUG_KMEMLEAK
select HAVE_DMA_CONTIGUOUS select HAVE_DMA_CONTIGUOUS
select HAVE_DYNAMIC_FTRACE select HAVE_DYNAMIC_FTRACE
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACER
select HAVE_PAGE_SIZE_4KB select HAVE_PAGE_SIZE_4KB

View File

@@ -73,7 +73,6 @@ config MIPS
select HAVE_EBPF_JIT if !CPU_MICROMIPS select HAVE_EBPF_JIT if !CPU_MICROMIPS
select HAVE_EXIT_THREAD select HAVE_EXIT_THREAD
select HAVE_GUP_FAST select HAVE_GUP_FAST
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACER
select HAVE_GCC_PLUGINS select HAVE_GCC_PLUGINS

View File

@@ -81,7 +81,6 @@ config PARISC
select HAVE_KPROBES select HAVE_KPROBES
select HAVE_KRETPROBES select HAVE_KRETPROBES
select HAVE_DYNAMIC_FTRACE if $(cc-option,-fpatchable-function-entry=1,1) select HAVE_DYNAMIC_FTRACE if $(cc-option,-fpatchable-function-entry=1,1)
select HAVE_FTRACE_MCOUNT_RECORD if HAVE_DYNAMIC_FTRACE
select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
select HAVE_KPROBES_ON_FTRACE select HAVE_KPROBES_ON_FTRACE
select HAVE_DYNAMIC_FTRACE_WITH_REGS select HAVE_DYNAMIC_FTRACE_WITH_REGS

View File

@@ -246,7 +246,6 @@ config PPC
select HAVE_EFFICIENT_UNALIGNED_ACCESS select HAVE_EFFICIENT_UNALIGNED_ACCESS
select HAVE_GUP_FAST select HAVE_GUP_FAST
select HAVE_FTRACE_GRAPH_FUNC select HAVE_FTRACE_GRAPH_FUNC
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_FUNCTION_ARG_ACCESS_API
select HAVE_FUNCTION_DESCRIPTORS if PPC64_ELF_ABI_V1 select HAVE_FUNCTION_DESCRIPTORS if PPC64_ELF_ABI_V1
select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_ERROR_INJECTION

View File

@@ -159,7 +159,6 @@ config RISCV
select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS if (DYNAMIC_FTRACE_WITH_ARGS && !CFI_CLANG) select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS if (DYNAMIC_FTRACE_WITH_ARGS && !CFI_CLANG)
select HAVE_DYNAMIC_FTRACE_WITH_ARGS if HAVE_DYNAMIC_FTRACE select HAVE_DYNAMIC_FTRACE_WITH_ARGS if HAVE_DYNAMIC_FTRACE
select HAVE_FTRACE_GRAPH_FUNC select HAVE_FTRACE_GRAPH_FUNC
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
select HAVE_FUNCTION_GRAPH_TRACER if HAVE_DYNAMIC_FTRACE_WITH_ARGS select HAVE_FUNCTION_GRAPH_TRACER if HAVE_DYNAMIC_FTRACE_WITH_ARGS
select HAVE_FUNCTION_GRAPH_FREGS select HAVE_FUNCTION_GRAPH_FREGS
select HAVE_FUNCTION_TRACER if !XIP_KERNEL select HAVE_FUNCTION_TRACER if !XIP_KERNEL

View File

@@ -199,7 +199,6 @@ config S390
select HAVE_GUP_FAST select HAVE_GUP_FAST
select HAVE_FENTRY select HAVE_FENTRY
select HAVE_FTRACE_GRAPH_FUNC select HAVE_FTRACE_GRAPH_FUNC
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_FUNCTION_ARG_ACCESS_API
select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_FREGS select HAVE_FUNCTION_GRAPH_FREGS

View File

@@ -40,7 +40,6 @@ config SUPERH
select HAVE_GUP_FAST if MMU select HAVE_GUP_FAST if MMU
select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACER
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_HW_BREAKPOINT select HAVE_HW_BREAKPOINT
select HAVE_IOREMAP_PROT if MMU && !X2TLB select HAVE_IOREMAP_PROT if MMU && !X2TLB
select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_BZIP2

View File

@@ -78,7 +78,6 @@ config SPARC64
select MMU_GATHER_NO_FLUSH_CACHE select MMU_GATHER_NO_FLUSH_CACHE
select HAVE_ARCH_TRANSPARENT_HUGEPAGE select HAVE_ARCH_TRANSPARENT_HUGEPAGE
select HAVE_DYNAMIC_FTRACE select HAVE_DYNAMIC_FTRACE
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_PAGE_SIZE_8KB select HAVE_PAGE_SIZE_8KB
select HAVE_SYSCALL_TRACEPOINTS select HAVE_SYSCALL_TRACEPOINTS
select HAVE_CONTEXT_TRACKING_USER select HAVE_CONTEXT_TRACKING_USER

View File

@@ -244,7 +244,6 @@ config X86
select HAVE_GUP_FAST select HAVE_GUP_FAST
select HAVE_FENTRY if X86_64 || DYNAMIC_FTRACE select HAVE_FENTRY if X86_64 || DYNAMIC_FTRACE
select HAVE_FTRACE_GRAPH_FUNC if HAVE_FUNCTION_GRAPH_TRACER select HAVE_FTRACE_GRAPH_FUNC if HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_GRAPH_FREGS if HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_GRAPH_FREGS if HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_GRAPH_TRACER if X86_32 || (X86_64 && DYNAMIC_FTRACE) select HAVE_FUNCTION_GRAPH_TRACER if X86_32 || (X86_64 && DYNAMIC_FTRACE)
select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACER

View File

@@ -167,7 +167,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
#define FTRACE_STUB_HACK #define FTRACE_STUB_HACK
#endif #endif
#ifdef CONFIG_FTRACE_MCOUNT_RECORD #ifdef CONFIG_DYNAMIC_FTRACE
/* /*
* The ftrace call sites are logged to a section whose name depends on the * The ftrace call sites are logged to a section whose name depends on the
* compiler option used. A given kernel image will only use one, AKA * compiler option used. A given kernel image will only use one, AKA

View File

@@ -1108,7 +1108,7 @@ static __always_inline unsigned long get_lock_parent_ip(void)
# define trace_preempt_off(a0, a1) do { } while (0) # define trace_preempt_off(a0, a1) do { } while (0)
#endif #endif
#ifdef CONFIG_FTRACE_MCOUNT_RECORD #ifdef CONFIG_DYNAMIC_FTRACE
extern void ftrace_init(void); extern void ftrace_init(void);
#ifdef CC_USING_PATCHABLE_FUNCTION_ENTRY #ifdef CC_USING_PATCHABLE_FUNCTION_ENTRY
#define FTRACE_CALLSITE_SECTION "__patchable_function_entries" #define FTRACE_CALLSITE_SECTION "__patchable_function_entries"

View File

@@ -373,9 +373,9 @@ ftrace_vprintk(const char *fmt, va_list ap)
static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
#endif /* CONFIG_TRACING */ #endif /* CONFIG_TRACING */
/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ /* Rebuild everything on CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FTRACE_MCOUNT_RECORD #ifdef CONFIG_DYNAMIC_FTRACE
# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_DYNAMIC_FTRACE
#endif #endif
/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ /* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */

View File

@@ -539,7 +539,7 @@ struct module {
struct trace_eval_map **trace_evals; struct trace_eval_map **trace_evals;
unsigned int num_trace_evals; unsigned int num_trace_evals;
#endif #endif
#ifdef CONFIG_FTRACE_MCOUNT_RECORD #ifdef CONFIG_DYNAMIC_FTRACE
unsigned int num_ftrace_callsites; unsigned int num_ftrace_callsites;
unsigned long *ftrace_callsites; unsigned long *ftrace_callsites;
#endif #endif

View File

@@ -2639,7 +2639,7 @@ static int find_module_sections(struct module *mod, struct load_info *info)
sizeof(*mod->trace_bprintk_fmt_start), sizeof(*mod->trace_bprintk_fmt_start),
&mod->num_trace_bprintk_fmt); &mod->num_trace_bprintk_fmt);
#endif #endif
#ifdef CONFIG_FTRACE_MCOUNT_RECORD #ifdef CONFIG_DYNAMIC_FTRACE
/* sechdrs[0].sh_size is always zero */ /* sechdrs[0].sh_size is always zero */
mod->ftrace_callsites = section_objs(info, FTRACE_CALLSITE_SECTION, mod->ftrace_callsites = section_objs(info, FTRACE_CALLSITE_SECTION,
sizeof(*mod->ftrace_callsites), sizeof(*mod->ftrace_callsites),

View File

@@ -74,11 +74,6 @@ config HAVE_DYNAMIC_FTRACE_NO_PATCHABLE
If the architecture generates __patchable_function_entries sections If the architecture generates __patchable_function_entries sections
but does not want them included in the ftrace locations. but does not want them included in the ftrace locations.
config HAVE_FTRACE_MCOUNT_RECORD
bool
help
See Documentation/trace/ftrace-design.rst
config HAVE_SYSCALL_TRACEPOINTS config HAVE_SYSCALL_TRACEPOINTS
bool bool
help help
@@ -803,27 +798,22 @@ config BPF_KPROBE_OVERRIDE
Allows BPF to override the execution of a probed function and Allows BPF to override the execution of a probed function and
set a different return value. This is used for error injection. set a different return value. This is used for error injection.
config FTRACE_MCOUNT_RECORD
def_bool y
depends on DYNAMIC_FTRACE
depends on HAVE_FTRACE_MCOUNT_RECORD
config FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY config FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
bool bool
depends on FTRACE_MCOUNT_RECORD depends on DYNAMIC_FTRACE
config FTRACE_MCOUNT_USE_CC config FTRACE_MCOUNT_USE_CC
def_bool y def_bool y
depends on $(cc-option,-mrecord-mcount) depends on $(cc-option,-mrecord-mcount)
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
depends on FTRACE_MCOUNT_RECORD depends on DYNAMIC_FTRACE
config FTRACE_MCOUNT_USE_OBJTOOL config FTRACE_MCOUNT_USE_OBJTOOL
def_bool y def_bool y
depends on HAVE_OBJTOOL_MCOUNT depends on HAVE_OBJTOOL_MCOUNT
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
depends on !FTRACE_MCOUNT_USE_CC depends on !FTRACE_MCOUNT_USE_CC
depends on FTRACE_MCOUNT_RECORD depends on DYNAMIC_FTRACE
select OBJTOOL select OBJTOOL
config FTRACE_MCOUNT_USE_RECORDMCOUNT config FTRACE_MCOUNT_USE_RECORDMCOUNT
@@ -831,7 +821,7 @@ config FTRACE_MCOUNT_USE_RECORDMCOUNT
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
depends on !FTRACE_MCOUNT_USE_CC depends on !FTRACE_MCOUNT_USE_CC
depends on !FTRACE_MCOUNT_USE_OBJTOOL depends on !FTRACE_MCOUNT_USE_OBJTOOL
depends on FTRACE_MCOUNT_RECORD depends on DYNAMIC_FTRACE
config TRACING_MAP config TRACING_MAP
bool bool

View File

@@ -1042,10 +1042,6 @@ static struct ftrace_ops *removed_ops;
*/ */
static bool update_all_ops; static bool update_all_ops;
#ifndef CONFIG_FTRACE_MCOUNT_RECORD
# error Dynamic ftrace depends on MCOUNT_RECORD
#endif
struct ftrace_func_probe { struct ftrace_func_probe {
struct ftrace_probe_ops *probe_ops; struct ftrace_probe_ops *probe_ops;
struct ftrace_ops ops; struct ftrace_ops ops;

View File

@@ -359,7 +359,7 @@ if ($arch eq "x86_64") {
$mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_CKCORE_PCREL_JSR_IMM26BY2\\s+_mcount\$"; $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_CKCORE_PCREL_JSR_IMM26BY2\\s+_mcount\$";
$alignment = 2; $alignment = 2;
} else { } else {
die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; die "Arch $arch is not supported with CONFIG_DYNAMIC_FTRACE";
} }
my $text_found = 0; my $text_found = 0;