Re: [PATCH v2 10/15] perf ftrace: add support for trace option sleep-time

From: Changbin Du
Date: Wed Jul 08 2020 - 08:59:31 EST


On Tue, Jul 07, 2020 at 01:09:43PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jul 07, 2020 at 11:35:14PM +0800, Changbin Du escreveu:
> > On Fri, Jul 03, 2020 at 03:40:59PM +0900, Namhyung Kim wrote:
> > > On Sat, Jun 27, 2020 at 10:38 PM Changbin Du <changbin.du@xxxxxxxxx> wrote:
> > > > This adds an option '--graph-nosleep-time' which allow us only to measure
> > > > on-CPU time. This option is function_graph tracer only.
>
> > > I'd suggest --graph-sleep-time instead and set it by default.
> > > Then we can have --no-graph-sleep-time as well.
>
> > If so can we make --graph-sleep-time as default. Seems there is no something
> > like OPT_BOOLEAN_DEFAULT().
>
> > > By the way, didn't we agree to have something like --graph-opts instead?
>
> > As I mentioned in previous version, --graph-opts make the parsing a little
> > complex.
> > --graph-opts depth=<n>,nosleep_time,noirqs,no_tail,verbose
>
> > While the exsiting style is '--graph-depth <n>'. The cons is we must type more
> > characters. The pros is don't need to reimplement parsing and align with old
> > behaviour.
> > --graph-depth <n>
> > --graph-nosleep-time
> > --graph-noirqs
> > --graph-notail
> > --graph-verbose
>
> This achieves the same result, yes, but it is more cumbersome, to use
> all we would have to do:
>
> perf ftrace --graph-depth 10 --graph-nosleep-time --graph-noirqs --graph-notail --graph-verbose ...
>
> When we could have a more compact:
>
> perf ftrace --graph-opts depth=10,nosleep-time,noirqs,notail,verbose ...
>
> I.e., instead of a series of:
>
> OPT_INTEGER(0, "graph-depth", &ftrace.graph_depth, "Max depth for function graph tracer"),
> OPT_BOOLEAN(0, "sleep-time", &ftrace.sleep_time, "explanation"),
> OPT_BOOLEAN(0, "irqs" &ftrace.irqs, "explanation"),
> OPT_BOOLEAN(0, "tail" &ftrace.tail, "explanation"),
> OPT_BOOLEAN(0, "verbose" &ftrace.verbose, "explanation"),
>
> We'd have a:
>
> OPT_CALLBACK(0, "graph-opts", &ftrace, "options", "graph options", parse_graph_opts),
>
> And parse_graph_opts() would just have a simple strchr(opt, ',') + if
> strcmp()/else loop, i.e., it would be easier for users, slightly more
> difficult for perf developers :-)
>
And we also have to parse key-value pairs for 'graph-depth' and move option
'--graph-depth' to 'graph-opts'.

There is an existing similr option '--debug'. It can be factored out as a
general interface.
--debug --debug verbose=2,stderr

> - Arnaldo

--
Cheers,
Changbin Du