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-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]>
---
 tools/perf/Documentation/perf-ftrace.txt |  3 +++
 tools/perf/builtin-ftrace.c              | 28 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 3c9eb044b7eb..cc770fc0a1e8 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -113,6 +113,9 @@ OPTIONS
 --graph-noirqs::
        Ignore functions that happen inside interrupt for function_graph tracer.
 
+--graph-verbose::
+       Show process names, PIDs, timestamps for function_graph tracer.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-trace[1]
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 0a1e481b66a0..e037fe7abd47 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -45,6 +45,7 @@ struct perf_ftrace {
        bool                    func_irq_info;
        bool                    graph_nosleep_time;
        bool                    graph_noirqs;
+       bool                    graph_verbose;
 };
 
 struct filter_entry {
@@ -205,6 +206,9 @@ static void reset_tracing_options(struct perf_ftrace 
*ftrace __maybe_unused)
        write_tracing_option_file("func_stack_trace", "0");
        write_tracing_option_file("sleep-time", "1");
        write_tracing_option_file("funcgraph-irqs", "1");
+       write_tracing_option_file("funcgraph-proc", "0");
+       write_tracing_option_file("funcgraph-abstime", "0");
+       write_tracing_option_file("latency-format", "0");
        write_tracing_option_file("irq-info", "0");
 }
 
@@ -419,6 +423,23 @@ static int set_tracing_funcgraph_irqs(struct perf_ftrace 
*ftrace)
        return 0;
 }
 
+static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace)
+{
+       if (!ftrace->graph_verbose)
+               return 0;
+
+       if (write_tracing_option_file("funcgraph-proc", "1") < 0)
+               return -1;
+
+       if (write_tracing_option_file("funcgraph-abstime", "1") < 0)
+               return -1;
+
+       if (write_tracing_option_file("latency-format", "1") < 0)
+               return -1;
+
+       return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
 {
        char *trace_file;
@@ -513,6 +534,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
                goto out_reset;
        }
 
+       if (set_tracing_funcgraph_verbose(ftrace) < 0) {
+               pr_err("failed to set tracing option 
funcgraph-proc/funcgraph-abstime\n");
+               goto out_reset;
+       }
+
        if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
                pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
                goto out_reset;
@@ -698,6 +724,8 @@ int cmd_ftrace(int argc, const char **argv)
                    "measure on-CPU time only for function_graph tracer"),
        OPT_BOOLEAN(0, "graph-noirqs", &ftrace.graph_noirqs,
                    "ignore functions that happen inside interrupt for 
function_graph tracer"),
+       OPT_BOOLEAN(0, "graph-verbose", &ftrace.graph_verbose,
+                   "show process names, PIDs, timestamps for function_graph 
tracer"),
        OPT_END()
        };
 
-- 
2.25.1

Reply via email to