Re: [PATCH 06/19] perf ftrace: add support for trace option sleep-time
On Sun, May 31, 2020 at 02:56:41PM +0900, Namhyung Kim wrote: > On Thu, May 21, 2020 at 6:01 AM Arnaldo Carvalho de Melo > wrote: > > > > 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 > > > > ? > > Agreed. Also I don't want to add an option in a negative form > as it's confusing. Actually, our option parser can recognize > --no-xxx form automatically so adding a positive option (--xxx) > can handle that too. > Agree. And for the name, maybe we can align to original trace options. root@WRT-WX9:/sys/kernel/debug/tracing# cat trace_options print-parent nosym-offset nosym-addr noverbose noraw nohex nobin noblock trace_printk annotate nouserstacktrace nosym-userobj noprintk-msg-only context-info nolatency-format record-cmd norecord-tgid overwrite nodisable_on_free irq-info markers noevent-fork function-trace nofunction-fork nodisplay-graph nostacktrace notest_nop_accept notest_nop_refuse > Thanks > Namhyung -- Cheers, Changbin Du
Re: [PATCH 06/19] perf ftrace: add support for trace option sleep-time
On Thu, May 21, 2020 at 6:01 AM Arnaldo Carvalho de Melo wrote: > > 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 > > ? Agreed. Also I don't want to add an option in a negative form as it's confusing. Actually, our option parser can recognize --no-xxx form automatically so adding a positive option (--xxx) can handle that too. Thanks Namhyung
Re: [PATCH 06/19] perf ftrace: add support for trace option sleep-time
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 > --- > 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_headnograph_funcs; > int graph_depth; > boolfunc_stack_trace; > + boolnosleep_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", _depth, > "Max depth for function graph tracer"), > + OPT_BOOLEAN(0, "nosleep-time", _time, > + "Measure on-CPU time only (function_graph only)"), > OPT_END() > }; > > -- > 2.25.1 > -- - Arnaldo
[PATCH 06/19] perf ftrace: add support for trace option sleep-time
This adds an option '--nosleep-time' which allow us only to measure on-CPU time. This option is function_graph tracer only. Signed-off-by: Changbin Du --- 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_headnograph_funcs; int graph_depth; boolfunc_stack_trace; + boolnosleep_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", _depth, "Max depth for function graph tracer"), + OPT_BOOLEAN(0, "nosleep-time", _time, + "Measure on-CPU time only (function_graph only)"), OPT_END() }; -- 2.25.1