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.

perf ftrace: Add 'tail' option to --graph-opts

The 'graph-tail' option is to print function name as a comment at the end.
This is useful when a large function is mixed with other functions
(possibly from different CPUs).

For example,

$ sudo perf ftrace -- perf stat true
...
1) | get_unused_fd_flags() {
1) | alloc_fd() {
1) 0.178 us | _raw_spin_lock();
1) 0.187 us | expand_files();
1) 0.169 us | _raw_spin_unlock();
1) 1.211 us | }
1) 1.503 us | }

$ sudo perf ftrace --graph-opts tail -- perf stat true
...
1) | get_unused_fd_flags() {
1) | alloc_fd() {
1) 0.099 us | _raw_spin_lock();
1) 0.083 us | expand_files();
1) 0.081 us | _raw_spin_unlock();
1) 0.601 us | } /* alloc_fd */
1) 0.751 us | } /* get_unused_fd_flags */

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Changbin Du <changbin.du@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/lkml/20240729004127.238611-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
c7780089 156e8dcf

+20
+1
tools/perf/Documentation/perf-ftrace.txt
··· 125 125 - verbose - Show process names, PIDs, timestamps, etc. 126 126 - thresh=<n> - Setup trace duration threshold in microseconds. 127 127 - depth=<n> - Set max depth for function graph tracer to follow. 128 + - tail - Print function name at the end. 128 129 129 130 130 131 OPTIONS for 'perf ftrace latency'
+18
tools/perf/builtin-ftrace.c
··· 228 228 write_tracing_option_file("funcgraph-irqs", "1"); 229 229 write_tracing_option_file("funcgraph-proc", "0"); 230 230 write_tracing_option_file("funcgraph-abstime", "0"); 231 + write_tracing_option_file("funcgraph-tail", "0"); 231 232 write_tracing_option_file("latency-format", "0"); 232 233 write_tracing_option_file("irq-info", "0"); 233 234 } ··· 465 464 return 0; 466 465 } 467 466 467 + static int set_tracing_funcgraph_tail(struct perf_ftrace *ftrace) 468 + { 469 + if (!ftrace->graph_tail) 470 + return 0; 471 + 472 + if (write_tracing_option_file("funcgraph-tail", "1") < 0) 473 + return -1; 474 + 475 + return 0; 476 + } 477 + 468 478 static int set_tracing_thresh(struct perf_ftrace *ftrace) 469 479 { 470 480 int ret; ··· 549 537 550 538 if (set_tracing_thresh(ftrace) < 0) { 551 539 pr_err("failed to set tracing thresh\n"); 540 + return -1; 541 + } 542 + 543 + if (set_tracing_funcgraph_tail(ftrace) < 0) { 544 + pr_err("failed to set tracing option funcgraph-tail\n"); 552 545 return -1; 553 546 } 554 547 ··· 1116 1099 { .name = "verbose", .value_ptr = &ftrace->graph_verbose }, 1117 1100 { .name = "thresh", .value_ptr = &ftrace->graph_thresh }, 1118 1101 { .name = "depth", .value_ptr = &ftrace->graph_depth }, 1102 + { .name = "tail", .value_ptr = &ftrace->graph_tail }, 1119 1103 { .name = NULL, } 1120 1104 }; 1121 1105
+1
tools/perf/util/ftrace.h
··· 25 25 int graph_noirqs; 26 26 int graph_verbose; 27 27 int graph_thresh; 28 + int graph_tail; 28 29 }; 29 30 30 31 struct filter_entry {