Re: [PATCH 06/19] perf ftrace: add support for trace option sleep-time

From: Arnaldo Carvalho de Melo
Date: Wed May 20 2020 - 17:01:11 EST


Em Sun, May 10, 2020 at 11:06:15PM +0800, Changbin Du escreveu:
> This adds an option '--nosleep-time' which allow us only to measure
> on-CPU time. This option is function_graph tracer only.

This seems, for now, very specific to the function_graph tracer, so
perhaps we should have a:

--function_graph_opts nosleep-time,other,another,etc

?

In time options that have equivalent in other perf tools can be
promoted?

- Arnaldo

> Signed-off-by: Changbin Du <changbin.du@xxxxxxxxx>
> ---
> 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 8133d910d5d8..d3fcf3b0b792 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -40,6 +40,7 @@ struct perf_ftrace {
> struct list_head nograph_funcs;
> int graph_depth;
> bool func_stack_trace;
> + bool nosleep_time;
> };
>
> struct filter_entry {
> @@ -186,6 +187,7 @@ static void reset_tracing_filters(void);
> 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");
> }
>
> static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
> @@ -345,6 +347,17 @@ static int set_tracing_depth(struct perf_ftrace *ftrace)
> return 0;
> }
>
> +static int set_tracing_sleep_time(struct perf_ftrace *ftrace)
> +{
> + if (!ftrace->nosleep_time)
> + return 0;
> +
> + if (write_tracing_option_file("sleep-time", "0") < 0)
> + return -1;
> +
> + return 0;
> +}
> +
> static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
> {
> char *trace_file;
> @@ -413,6 +426,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
> goto out_reset;
> }
>
> + if (set_tracing_sleep_time(ftrace) < 0) {
> + pr_err("failed to set tracing option sleep-time\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;
> @@ -548,6 +566,8 @@ int cmd_ftrace(int argc, const char **argv)
> parse_filter_func),
> OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
> "Max depth for function graph tracer"),
> + OPT_BOOLEAN(0, "nosleep-time", &ftrace.nosleep_time,
> + "Measure on-CPU time only (function_graph only)"),
> OPT_END()
> };
>
> --
> 2.25.1
>

--

- Arnaldo