Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Have function graph tracer define options per instance

Currently the function graph 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_graph > instances/foo/current_tracer
# echo 1 > options/funcgraph-args
# echo function_graph > current_tracer
# cat trace
[..]
2) | _raw_spin_lock_irq(lock=0xffff96b97dea16c0) {
2) 0.422 us | do_raw_spin_lock(lock=0xffff96b97dea16c0);
7) | rcu_sched_clock_irq(user=0) {
2) 1.478 us | }
7) 0.758 us | rcu_is_cpu_rrupt_from_idle();
2) 0.647 us | enqueue_hrtimer(timer=0xffff96b97dea2058, base=0xffff96b97dea1740, mode=0);
# cat instances/foo/options/funcgraph-args
1
# cat instances/foo/trace
[..]
4) | __x64_sys_read() {
4) | ksys_read() {
4) 0.755 us | fdget_pos();
4) | vfs_read() {
4) | rw_verify_area() {
4) | security_file_permission() {
4) | apparmor_file_permission() {
4) | common_file_perm() {
4) | aa_file_perm() {
4) | rcu_read_lock_held() {
[..]

The above shows that updating the "funcgraph-args" option at the top level
instance also updates the "funcgraph-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.641030027@kernel.org
Fixes: c132be2c4fcc1 ("function_graph: Have the instances use their own ftrace_ops for filtering")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+11 -7
+11 -7
kernel/trace/trace_functions_graph.c
··· 101 101 .opts = trace_opts 102 102 }; 103 103 104 - static bool tracer_flags_is_set(u32 flags) 104 + static bool tracer_flags_is_set(struct trace_array *tr, u32 flags) 105 105 { 106 - return (tracer_flags.val & flags) == flags; 106 + return (tr->current_trace_flags->val & flags) == flags; 107 107 } 108 108 109 109 /* ··· 263 263 264 264 trace_ctx = tracing_gen_ctx(); 265 265 if (IS_ENABLED(CONFIG_FUNCTION_GRAPH_RETADDR) && 266 - tracer_flags_is_set(TRACE_GRAPH_PRINT_RETADDR)) { 266 + tracer_flags_is_set(tr, TRACE_GRAPH_PRINT_RETADDR)) { 267 267 unsigned long retaddr = ftrace_graph_top_ret_addr(current); 268 268 ret = __trace_graph_retaddr_entry(tr, trace, trace_ctx, retaddr); 269 269 } else { ··· 441 441 { 442 442 int ret; 443 443 444 - if (tracer_flags_is_set(TRACE_GRAPH_ARGS)) 444 + if (tracer_flags_is_set(tr, TRACE_GRAPH_ARGS)) 445 445 tr->gops->entryfunc = trace_graph_entry_args; 446 446 else 447 447 tr->gops->entryfunc = trace_graph_entry; ··· 1459 1459 static enum print_line_t 1460 1460 print_graph_function(struct trace_iterator *iter) 1461 1461 { 1462 - return print_graph_function_flags(iter, tracer_flags.val); 1462 + struct trace_array *tr = iter->tr; 1463 + return print_graph_function_flags(iter, tr->current_trace_flags->val); 1463 1464 } 1464 1465 1465 1466 static enum print_line_t ··· 1536 1535 1537 1536 static void print_graph_headers(struct seq_file *s) 1538 1537 { 1539 - print_graph_headers_flags(s, tracer_flags.val); 1538 + struct trace_iterator *iter = s->private; 1539 + struct trace_array *tr = iter->tr; 1540 + 1541 + print_graph_headers_flags(s, tr->current_trace_flags->val); 1540 1542 } 1541 1543 1542 1544 void print_graph_headers_flags(struct seq_file *s, u32 flags) ··· 1664 1660 .reset = graph_trace_reset, 1665 1661 .print_line = print_graph_function, 1666 1662 .print_header = print_graph_headers, 1667 - .flags = &tracer_flags, 1663 + .default_flags = &tracer_flags, 1668 1664 .set_flag = func_graph_set_flag, 1669 1665 .allow_instances = true, 1670 1666 #ifdef CONFIG_FTRACE_SELFTEST