Re: [PATCH v1 1/2] perf auxtrace: Add 'T' itrace option for timestamp trace

From: Leo Yan
Date: Thu Oct 19 2023 - 07:52:43 EST


On Thu, Oct 19, 2023 at 11:31:16AM +0100, James Clark wrote:

[...]

> > --- a/tools/perf/Documentation/itrace.txt
> > +++ b/tools/perf/Documentation/itrace.txt
> > @@ -25,6 +25,7 @@
> > q quicker (less detailed) decoding
> > A approximate IPC
> > Z prefer to ignore timestamps (so-called "timeless" decoding)
> > + T use the timestamp trace as kernel time
> >
>
> Maybe "Treat hardware timestamps as kernel time (trace and CPU time use
> same clock source)" would be clearer.

Agreed.

> And another point, although this isn't really related to this patch, but
> why do we have the single letter arguments for itrace? It seems like it
> massively restricts the available options and makes the command lines
> hard to read because they don't have long forms. Why not just have them
> as normal arguments?

TBH, I tried a bit for adding a normal argument, but I found it's not
nature like itrace option for passing the normal argument into the
decoder. And if we add a normal argument, we need to consider adding
into perf commands for 'perf report', 'perf script', etc; itrace options
can be shared by perf output commands.

I understand an advantage of using normal argument is the 'perf report'
command (e.g. perf report --aux-trace-kernel-time) doesn't need to
specify any extra itrace option.

If anyone still has concern for adding itrace optiona and prefer to add
normal argument, I am happy to rework for adding normal argument.

> If it's a backwards compatibility thing, would there be any objection to
> adding this new option as a normal one rather than an itrace one?

backward compatibility would not a problem - we add a new feature and
at meantime we don't break anything.

> > The default is all events i.e. the same as --itrace=iybxwpe,
> > except for perf script where it is --itrace=ce
> > diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> > index a0368202a746..f528c4364d23 100644
> > --- a/tools/perf/util/auxtrace.c
> > +++ b/tools/perf/util/auxtrace.c
> > @@ -1638,6 +1638,9 @@ int itrace_do_parse_synth_opts(struct itrace_synth_opts *synth_opts,
> > case 'Z':
> > synth_opts->timeless_decoding = true;
> > break;
> > + case 'T':
> > + synth_opts->use_timestamp = true;
> > + break;
> > case ' ':
> > case ',':
> > break;
> > diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
> > index 29eb82dff574..55702215a82d 100644
> > --- a/tools/perf/util/auxtrace.h
> > +++ b/tools/perf/util/auxtrace.h
> > @@ -99,6 +99,7 @@ enum itrace_period_type {
> > * @remote_access: whether to synthesize remote access events
> > * @mem: whether to synthesize memory events
> > * @timeless_decoding: prefer "timeless" decoding i.e. ignore timestamps
> > + * @use_timestamp: use the timestamp trace as kernel time
> > * @vm_time_correlation: perform VM Time Correlation
> > * @vm_tm_corr_dry_run: VM Time Correlation dry-run
> > * @vm_tm_corr_args: VM Time Correlation implementation-specific arguments
> > @@ -146,6 +147,7 @@ struct itrace_synth_opts {
> > bool remote_access;
> > bool mem;
> > bool timeless_decoding;
> > + bool use_timestamp;
>
> And then this one could be like "hw_time_is_kernel_time", but I'm
> stuggling to think of something shorter. Maybe your one is fine along
> with the comment.

It's fine for me to rename as "hw_time_is_kernel_time" for more
readable. Will do in next spin.

Thanks,
Leo