Skip to content

Commit 59486fb

Browse files
changbinduacmel
authored andcommitted
perf ftrace: Add option 'verbose' to show more info for graph tracer
Sometimes we want ftrace display more and longer information about the trace. $ sudo perf ftrace -G '*' 2) 0.979 us | mutex_unlock(); 2) 1.540 us | __fsnotify_parent(); 2) 0.433 us | fsnotify(); $ sudo perf ftrace -G '*' --graph-opts verbose 14160.770883 | 0) <...>-47814 | .... | 1.289 us | mutex_unlock(); 14160.770886 | 0) <...>-47814 | .... | 1.624 us | __fsnotify_parent(); 14160.770887 | 0) <...>-47814 | .... | 0.636 us | fsnotify(); 14160.770888 | 0) <...>-47814 | .... | 0.328 us | __sb_end_write(); 14160.770888 | 0) <...>-47814 | d... | 0.430 us | fpregs_assert_state_consistent(); 14160.770889 | 0) <...>-47814 | d... | | do_syscall_64() { 14160.770889 | 0) <...>-47814 | .... | | __x64_sys_close() { Signed-off-by: Changbin Du <[email protected]> Acked-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c81fc34 commit 59486fb

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

tools/perf/Documentation/perf-ftrace.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ OPTIONS
106106
List of options allowed to set:
107107
nosleep-time - Measure on-CPU time only for function_graph tracer.
108108
noirqs - Ignore functions that happen inside interrupt.
109+
verbose - Show process names, PIDs, timestamps, etc.
109110

110111
SEE ALSO
111112
--------

tools/perf/builtin-ftrace.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct perf_ftrace {
4747
int func_irq_info;
4848
int graph_nosleep_time;
4949
int graph_noirqs;
50+
int graph_verbose;
5051
};
5152

5253
struct filter_entry {
@@ -210,6 +211,9 @@ static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused)
210211
write_tracing_option_file("func_stack_trace", "0");
211212
write_tracing_option_file("sleep-time", "1");
212213
write_tracing_option_file("funcgraph-irqs", "1");
214+
write_tracing_option_file("funcgraph-proc", "0");
215+
write_tracing_option_file("funcgraph-abstime", "0");
216+
write_tracing_option_file("latency-format", "0");
213217
write_tracing_option_file("irq-info", "0");
214218
}
215219

@@ -425,6 +429,23 @@ static int set_tracing_funcgraph_irqs(struct perf_ftrace *ftrace)
425429
return 0;
426430
}
427431

432+
static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace)
433+
{
434+
if (!ftrace->graph_verbose)
435+
return 0;
436+
437+
if (write_tracing_option_file("funcgraph-proc", "1") < 0)
438+
return -1;
439+
440+
if (write_tracing_option_file("funcgraph-abstime", "1") < 0)
441+
return -1;
442+
443+
if (write_tracing_option_file("latency-format", "1") < 0)
444+
return -1;
445+
446+
return 0;
447+
}
448+
428449
static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
429450
{
430451
char *trace_file;
@@ -519,6 +540,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
519540
goto out_reset;
520541
}
521542

543+
if (set_tracing_funcgraph_verbose(ftrace) < 0) {
544+
pr_err("failed to set tracing option funcgraph-proc/funcgraph-abstime\n");
545+
goto out_reset;
546+
}
547+
522548
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
523549
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
524550
goto out_reset;
@@ -700,6 +726,7 @@ static int parse_graph_tracer_opts(const struct option *opt,
700726
struct sublevel_option graph_tracer_opts[] = {
701727
{ .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time },
702728
{ .name = "noirqs", .value_ptr = &ftrace->graph_noirqs },
729+
{ .name = "verbose", .value_ptr = &ftrace->graph_verbose },
703730
{ .name = NULL, }
704731
};
705732

@@ -771,7 +798,7 @@ int cmd_ftrace(int argc, const char **argv)
771798
OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
772799
"Max depth for function graph tracer"),
773800
OPT_CALLBACK(0, "graph-opts", &ftrace, "options",
774-
"graph tracer options, available options: nosleep-time,noirqs",
801+
"graph tracer options, available options: nosleep-time,noirqs,verbose",
775802
parse_graph_tracer_opts),
776803
OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size",
777804
"size of per cpu buffer", parse_buffer_size),

0 commit comments

Comments
 (0)