mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
Merge tag 'ftrace-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull ftrace updates from Steven Rostedt: - Keep track of when fgraph_ops are registered or not Keep accounting of when fgraph_ops are registered as if a fgraph_ops is registered twice it can mess up the accounting and it will not work as expected later. Trigger a warning if something registers it twice as to catch bugs before they are found by things just not working as expected. - Make DYNAMIC_FTRACE always enabled for architectures that support it As static ftrace (where all functions are always traced) is very expensive and only exists to help architectures support ftrace, do not make it an option. As soon as an architecture supports DYNAMIC_FTRACE make it use it. This simplifies the code. - Remove redundant config HAVE_FTRACE_MCOUNT_RECORD 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. - Make pid_ptr string size match the comment In print_graph_proc() the pid_ptr string is of size 11, but the comment says /* sign + log10(MAX_INT) + '\0' */ which is actually 12. * tag 'ftrace-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Remove redundant config HAVE_FTRACE_MCOUNT_RECORD ftrace: Make DYNAMIC_FTRACE always enabled for architectures that support it fgraph: Keep track of when fgraph_ops are registered or not fgraph: Make pid_str size match the comment
This commit is contained in:
@@ -238,19 +238,15 @@ You need very few things to get the syscalls tracing in an arch.
|
||||
- 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
|
||||
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.
|
||||
|
||||
|
||||
HAVE_DYNAMIC_FTRACE
|
||||
-------------------
|
||||
|
||||
You will first need HAVE_FTRACE_MCOUNT_RECORD and HAVE_FUNCTION_TRACER, so
|
||||
scroll your reader back up if you got over eager.
|
||||
You will first need 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:
|
||||
- asm/ftrace.h:
|
||||
|
||||
@@ -105,7 +105,6 @@ config ARM
|
||||
select HAVE_EFFICIENT_UNALIGNED_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && MMU
|
||||
select HAVE_EXIT_THREAD
|
||||
select HAVE_GUP_FAST if ARM_LPAE
|
||||
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
|
||||
select HAVE_FUNCTION_ERROR_INJECTION
|
||||
select HAVE_FUNCTION_GRAPH_TRACER
|
||||
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
|
||||
|
||||
@@ -221,7 +221,6 @@ config ARM64
|
||||
select HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
select HAVE_GUP_FAST
|
||||
select HAVE_FTRACE_GRAPH_FUNC
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_FUNCTION_TRACER
|
||||
select HAVE_FUNCTION_ERROR_INJECTION
|
||||
select HAVE_FUNCTION_GRAPH_FREGS
|
||||
|
||||
@@ -80,7 +80,6 @@ config CSKY
|
||||
select HAVE_FUNCTION_TRACER
|
||||
select HAVE_FUNCTION_GRAPH_TRACER
|
||||
select HAVE_FUNCTION_ERROR_INJECTION
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_KERNEL_GZIP
|
||||
select HAVE_KERNEL_LZO
|
||||
select HAVE_KERNEL_LZMA
|
||||
|
||||
@@ -143,7 +143,6 @@ config LOONGARCH
|
||||
select HAVE_EXIT_THREAD
|
||||
select HAVE_GUP_FAST
|
||||
select HAVE_FTRACE_GRAPH_FUNC
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_FUNCTION_ARG_ACCESS_API
|
||||
select HAVE_FUNCTION_ERROR_INJECTION
|
||||
select HAVE_FUNCTION_GRAPH_FREGS
|
||||
|
||||
@@ -28,7 +28,6 @@ config MICROBLAZE
|
||||
select HAVE_DEBUG_KMEMLEAK
|
||||
select HAVE_DMA_CONTIGUOUS
|
||||
select HAVE_DYNAMIC_FTRACE
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_FUNCTION_GRAPH_TRACER
|
||||
select HAVE_FUNCTION_TRACER
|
||||
select HAVE_PAGE_SIZE_4KB
|
||||
|
||||
@@ -73,7 +73,6 @@ config MIPS
|
||||
select HAVE_EBPF_JIT if !CPU_MICROMIPS
|
||||
select HAVE_EXIT_THREAD
|
||||
select HAVE_GUP_FAST
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_FUNCTION_GRAPH_TRACER
|
||||
select HAVE_FUNCTION_TRACER
|
||||
select HAVE_GCC_PLUGINS
|
||||
|
||||
@@ -81,7 +81,6 @@ config PARISC
|
||||
select HAVE_KPROBES
|
||||
select HAVE_KRETPROBES
|
||||
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 HAVE_KPROBES_ON_FTRACE
|
||||
select HAVE_DYNAMIC_FTRACE_WITH_REGS
|
||||
|
||||
@@ -244,7 +244,6 @@ config PPC
|
||||
select HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
select HAVE_GUP_FAST
|
||||
select HAVE_FTRACE_GRAPH_FUNC
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_FUNCTION_ARG_ACCESS_API
|
||||
select HAVE_FUNCTION_DESCRIPTORS if PPC64_ELF_ABI_V1
|
||||
select HAVE_FUNCTION_ERROR_INJECTION
|
||||
|
||||
@@ -157,7 +157,6 @@ config RISCV
|
||||
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_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_FREGS
|
||||
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && HAVE_DYNAMIC_FTRACE
|
||||
|
||||
@@ -198,7 +198,6 @@ config S390
|
||||
select HAVE_GUP_FAST
|
||||
select HAVE_FENTRY
|
||||
select HAVE_FTRACE_GRAPH_FUNC
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_FUNCTION_ARG_ACCESS_API
|
||||
select HAVE_FUNCTION_ERROR_INJECTION
|
||||
select HAVE_FUNCTION_GRAPH_FREGS
|
||||
|
||||
@@ -40,7 +40,6 @@ config SUPERH
|
||||
select HAVE_GUP_FAST if MMU
|
||||
select HAVE_FUNCTION_GRAPH_TRACER
|
||||
select HAVE_FUNCTION_TRACER
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_HW_BREAKPOINT
|
||||
select HAVE_IOREMAP_PROT if MMU && !X2TLB
|
||||
select HAVE_KERNEL_BZIP2
|
||||
|
||||
@@ -78,7 +78,6 @@ config SPARC64
|
||||
select MMU_GATHER_NO_FLUSH_CACHE
|
||||
select HAVE_ARCH_TRANSPARENT_HUGEPAGE
|
||||
select HAVE_DYNAMIC_FTRACE
|
||||
select HAVE_FTRACE_MCOUNT_RECORD
|
||||
select HAVE_PAGE_SIZE_8KB
|
||||
select HAVE_SYSCALL_TRACEPOINTS
|
||||
select HAVE_CONTEXT_TRACKING_USER
|
||||
|
||||
@@ -242,7 +242,6 @@ config X86
|
||||
select HAVE_GUP_FAST
|
||||
select HAVE_FENTRY if X86_64 || DYNAMIC_FTRACE
|
||||
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_TRACER if X86_32 || (X86_64 && DYNAMIC_FTRACE)
|
||||
select HAVE_FUNCTION_TRACER
|
||||
|
||||
@@ -167,7 +167,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
|
||||
#define FTRACE_STUB_HACK
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||
/*
|
||||
* 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
|
||||
|
||||
@@ -1108,7 +1108,7 @@ static __always_inline unsigned long get_lock_parent_ip(void)
|
||||
# define trace_preempt_off(a0, a1) do { } while (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||
extern void ftrace_init(void);
|
||||
#ifdef CC_USING_PATCHABLE_FUNCTION_ENTRY
|
||||
#define FTRACE_CALLSITE_SECTION "__patchable_function_entries"
|
||||
|
||||
@@ -373,9 +373,9 @@ ftrace_vprintk(const char *fmt, va_list ap)
|
||||
static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
|
||||
#endif /* CONFIG_TRACING */
|
||||
|
||||
/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
|
||||
/* Rebuild everything on CONFIG_DYNAMIC_FTRACE */
|
||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||
# define REBUILD_DUE_TO_DYNAMIC_FTRACE
|
||||
#endif
|
||||
|
||||
/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */
|
||||
|
||||
@@ -539,7 +539,7 @@ struct module {
|
||||
struct trace_eval_map **trace_evals;
|
||||
unsigned int num_trace_evals;
|
||||
#endif
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||
unsigned int num_ftrace_callsites;
|
||||
unsigned long *ftrace_callsites;
|
||||
#endif
|
||||
|
||||
@@ -2673,7 +2673,7 @@ static int find_module_sections(struct module *mod, struct load_info *info)
|
||||
sizeof(*mod->trace_bprintk_fmt_start),
|
||||
&mod->num_trace_bprintk_fmt);
|
||||
#endif
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||
/* sechdrs[0].sh_size is always zero */
|
||||
mod->ftrace_callsites = section_objs(info, FTRACE_CALLSITE_SECTION,
|
||||
sizeof(*mod->ftrace_callsites),
|
||||
|
||||
@@ -74,11 +74,6 @@ config HAVE_DYNAMIC_FTRACE_NO_PATCHABLE
|
||||
If the architecture generates __patchable_function_entries sections
|
||||
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
|
||||
bool
|
||||
help
|
||||
@@ -275,7 +270,7 @@ config FUNCTION_TRACE_ARGS
|
||||
funcgraph-args (for the function graph tracer)
|
||||
|
||||
config DYNAMIC_FTRACE
|
||||
bool "enable/disable function tracing dynamically"
|
||||
bool
|
||||
depends on FUNCTION_TRACER
|
||||
depends on HAVE_DYNAMIC_FTRACE
|
||||
default y
|
||||
@@ -803,27 +798,22 @@ config BPF_KPROBE_OVERRIDE
|
||||
Allows BPF to override the execution of a probed function and
|
||||
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
|
||||
bool
|
||||
depends on FTRACE_MCOUNT_RECORD
|
||||
depends on DYNAMIC_FTRACE
|
||||
|
||||
config FTRACE_MCOUNT_USE_CC
|
||||
def_bool y
|
||||
depends on $(cc-option,-mrecord-mcount)
|
||||
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
|
||||
depends on FTRACE_MCOUNT_RECORD
|
||||
depends on DYNAMIC_FTRACE
|
||||
|
||||
config FTRACE_MCOUNT_USE_OBJTOOL
|
||||
def_bool y
|
||||
depends on HAVE_OBJTOOL_MCOUNT
|
||||
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
|
||||
depends on !FTRACE_MCOUNT_USE_CC
|
||||
depends on FTRACE_MCOUNT_RECORD
|
||||
depends on DYNAMIC_FTRACE
|
||||
select OBJTOOL
|
||||
|
||||
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_CC
|
||||
depends on !FTRACE_MCOUNT_USE_OBJTOOL
|
||||
depends on FTRACE_MCOUNT_RECORD
|
||||
depends on DYNAMIC_FTRACE
|
||||
|
||||
config TRACING_MAP
|
||||
bool
|
||||
|
||||
@@ -1325,6 +1325,10 @@ int register_ftrace_graph(struct fgraph_ops *gops)
|
||||
int ret = 0;
|
||||
int i = -1;
|
||||
|
||||
if (WARN_ONCE(gops->ops.flags & FTRACE_OPS_FL_GRAPH,
|
||||
"function graph ops registered again"))
|
||||
return -EBUSY;
|
||||
|
||||
guard(mutex)(&ftrace_lock);
|
||||
|
||||
if (!fgraph_stack_cachep) {
|
||||
@@ -1401,17 +1405,21 @@ void unregister_ftrace_graph(struct fgraph_ops *gops)
|
||||
{
|
||||
int command = 0;
|
||||
|
||||
if (WARN_ONCE(!(gops->ops.flags & FTRACE_OPS_FL_GRAPH),
|
||||
"function graph ops unregistered without registering"))
|
||||
return;
|
||||
|
||||
guard(mutex)(&ftrace_lock);
|
||||
|
||||
if (unlikely(!ftrace_graph_active))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (unlikely(gops->idx < 0 || gops->idx >= FGRAPH_ARRAY_SIZE ||
|
||||
fgraph_array[gops->idx] != gops))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (fgraph_lru_release_index(gops->idx) < 0)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
fgraph_array[gops->idx] = &fgraph_stub;
|
||||
|
||||
@@ -1434,4 +1442,6 @@ void unregister_ftrace_graph(struct fgraph_ops *gops)
|
||||
unregister_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
|
||||
}
|
||||
gops->saved_func = NULL;
|
||||
out:
|
||||
gops->ops.flags &= ~FTRACE_OPS_FL_GRAPH;
|
||||
}
|
||||
|
||||
@@ -1042,10 +1042,6 @@ static struct ftrace_ops *removed_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_probe_ops *probe_ops;
|
||||
struct ftrace_ops ops;
|
||||
|
||||
@@ -513,7 +513,7 @@ static void print_graph_proc(struct trace_seq *s, pid_t pid)
|
||||
{
|
||||
char comm[TASK_COMM_LEN];
|
||||
/* sign + log10(MAX_INT) + '\0' */
|
||||
char pid_str[11];
|
||||
char pid_str[12];
|
||||
int spaces = 0;
|
||||
int len;
|
||||
int i;
|
||||
|
||||
@@ -359,7 +359,7 @@ if ($arch eq "x86_64") {
|
||||
$mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_CKCORE_PCREL_JSR_IMM26BY2\\s+_mcount\$";
|
||||
$alignment = 2;
|
||||
} 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;
|
||||
|
||||
Reference in New Issue
Block a user