Em Sun, May 10, 2020 at 11:06:19PM +0800, Changbin Du escreveu:
> This adds an option '--funcgraph-tail' for function graph tracer.

And I think we should make these available in a compact way, as Intel PT
has, i.e. instead of doing something like:

   --function-graph-options nosleep_time,noirqs,no_tail,long_info

We could have:

   -G ns,ni,nt,li

To save on typing, or something like that.

- Arnaldo
 
> Signed-off-by: Changbin Du <[email protected]>
> ---
>  tools/perf/builtin-ftrace.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index 20bc14d6c5fb..2ef5d1c4b23c 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -42,6 +42,7 @@ struct perf_ftrace {
>       bool                    func_stack_trace;
>       bool                    nosleep_time;
>       bool                    nofuncgraph_irqs;
> +     bool                    funcgraph_tail;
>       bool                    long_info;
>       unsigned                tracing_thresh;
>  };
> @@ -192,6 +193,7 @@ 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-tail", "0");
>       write_tracing_option_file("funcgraph-proc", "0");
>       write_tracing_option_file("funcgraph-abstime", "0");
>       write_tracing_option_file("irq-info", "0");
> @@ -411,6 +413,17 @@ static int set_tracing_thresh(struct perf_ftrace *ftrace)
>       return 0;
>  }
>  
> +static int set_tracing_funcgraph_tail(struct perf_ftrace *ftrace)
> +{
> +     if (!ftrace->funcgraph_tail)
> +             return 0;
> +
> +     if (write_tracing_option_file("funcgraph-tail", "1") < 0)
> +             return -1;
> +
> +     return 0;
> +}
> +
>  static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
> **argv)
>  {
>       char *trace_file;
> @@ -499,6 +512,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
> argc, const char **argv)
>               goto out_reset;
>       }
>  
> +     if (set_tracing_funcgraph_tail(ftrace) < 0) {
> +             pr_err("failed to set tracing option funcgraph-tail\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;
> @@ -638,6 +656,8 @@ int cmd_ftrace(int argc, const char **argv)
>                   "Measure on-CPU time only (function_graph only)"),
>       OPT_BOOLEAN(0, "nofuncgraph-irqs", &ftrace.nofuncgraph_irqs,
>                   "Ignore functions that happen inside interrupt 
> (function_graph only)"),
> +     OPT_BOOLEAN(0, "funcgraph-tail", &ftrace.funcgraph_tail,
> +                 "Show function tails comment (function_graph only)"),
>       OPT_BOOLEAN('l', "long-info", &ftrace.long_info,
>                   "Show process names, PIDs, timestamps, irq-info if 
> available"),
>       OPT_UINTEGER(0, "tracing-thresh", &ftrace.tracing_thresh,
> -- 
> 2.25.1
> 

-- 

- Arnaldo

Reply via email to