Skip to content

Commit 76680d0

Browse files
committed
tracing: Have function tracer define options per instance
Currently the function tracer's options are saved via a global mask when it should be per instance. Use the new infrastructure to define a "default_flags" field in the tracer structure that is used for the top level instance as well as new ones. Currently the global mask causes confusion: # cd /sys/kernel/tracing # mkdir instances/foo # echo function > instances/foo/current_tracer # echo 1 > options/func-args # echo function > current_tracer # cat trace [..] <idle>-0 [005] d..3. 1050.656187: rcu_needs_cpu() <-tick_nohz_next_event <idle>-0 [005] d..3. 1050.656188: get_next_timer_interrupt(basej=0x10002dbad, basem=0xf45fd7d300) <-tick_nohz_next_event <idle>-0 [005] d..3. 1050.656189: _raw_spin_lock(lock=0xffff8944bdf5de80) <-__get_next_timer_interrupt <idle>-0 [005] d..4. 1050.656190: do_raw_spin_lock(lock=0xffff8944bdf5de80) <-__get_next_timer_interrupt <idle>-0 [005] d..4. 1050.656191: _raw_spin_lock_nested(lock=0xffff8944bdf5f140, subclass=1) <-__get_next_timer_interrupt # cat instances/foo/options/func-args 1 # cat instances/foo/trace [..] kworker/4:1-88 [004] ...1. 298.127735: next_zone <-refresh_cpu_vm_stats kworker/4:1-88 [004] ...1. 298.127736: first_online_pgdat <-refresh_cpu_vm_stats kworker/4:1-88 [004] ...1. 298.127738: next_online_pgdat <-refresh_cpu_vm_stats kworker/4:1-88 [004] ...1. 298.127739: fold_diff <-refresh_cpu_vm_stats kworker/4:1-88 [004] ...1. 298.127741: round_jiffies_relative <-vmstat_update [..] The above shows that updating the "func-args" option at the top level instance also updates the "func-args" option in the instance but because the update is only done by the instance that gets changed (as it should), it's confusing to see that the option is already set in the other instance. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://patch.msgid.link/20251111232429.470883736@kernel.org Fixes: f20a580 ("ftrace: Allow instances to use function tracing") Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 428add5 commit 76680d0

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

kernel/trace/trace_functions.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ static int function_trace_init(struct trace_array *tr)
154154
if (!tr->ops)
155155
return -ENOMEM;
156156

157-
func = select_trace_function(func_flags.val);
157+
func = select_trace_function(tr->current_trace_flags->val);
158158
if (!func)
159159
return -EINVAL;
160160

161-
if (!handle_func_repeats(tr, func_flags.val))
161+
if (!handle_func_repeats(tr, tr->current_trace_flags->val))
162162
return -ENOMEM;
163163

164164
ftrace_init_array_ops(tr, func);
@@ -459,14 +459,14 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
459459
u32 new_flags;
460460

461461
/* Do nothing if already set. */
462-
if (!!set == !!(func_flags.val & bit))
462+
if (!!set == !!(tr->current_trace_flags->val & bit))
463463
return 0;
464464

465465
/* We can change this flag only when not running. */
466466
if (tr->current_trace != &function_trace)
467467
return 0;
468468

469-
new_flags = (func_flags.val & ~bit) | (set ? bit : 0);
469+
new_flags = (tr->current_trace_flags->val & ~bit) | (set ? bit : 0);
470470
func = select_trace_function(new_flags);
471471
if (!func)
472472
return -EINVAL;
@@ -491,7 +491,7 @@ static struct tracer function_trace __tracer_data =
491491
.init = function_trace_init,
492492
.reset = function_trace_reset,
493493
.start = function_trace_start,
494-
.flags = &func_flags,
494+
.default_flags = &func_flags,
495495
.set_flag = func_set_flag,
496496
.allow_instances = true,
497497
#ifdef CONFIG_FTRACE_SELFTEST

0 commit comments

Comments
 (0)