Re: [PATCH 2/6] perf tools: Store clock references for -k/--clockid option

From: Jiri Olsa
Date: Mon Aug 03 2020 - 07:36:31 EST


On Mon, Aug 03, 2020 at 12:55:50PM +0900, Namhyung Kim wrote:

SNIP

> > diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt
> > index b6472e463284..c484e81987c7 100644
> > --- a/tools/perf/Documentation/perf.data-file-format.txt
> > +++ b/tools/perf/Documentation/perf.data-file-format.txt
> > @@ -389,6 +389,19 @@ struct {
> > Example:
> > cpu pmu capabilities: branches=32, max_precise=3, pmu_name=icelake
> >
> > + HEADER_CLOCK_DATA = 29,
> > +
> > + Contains clock id and its reference time together with wall clock
> > + time taken at the 'same time', both values are in nanoseconds.
> > + The format of data is as below.
> > +
> > +struct {
> > + u32 version; /* version = 1 */
> > + u32 clockid;
> > + u64 clockid_time_ns;
> > + u64 wall_clock_ns;
> > +};
> > +
>
> It seems that it's slightly different than what it actually write to a file.
> Specifically the last two fields should be reversed IMHO.

oops, you're right.. wil fix in new version

>
>
> > other bits are reserved and should ignored for now
> > HEADER_FEAT_BITS = 256,
> >
> [SNIP]
>
> > diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h
> > index 1ab2682d5d2b..4098a63d5e64 100644
> > --- a/tools/perf/util/env.h
> > +++ b/tools/perf/util/env.h
> > @@ -100,6 +100,18 @@ struct perf_env {
> > /* For fast cpu to numa node lookup via perf_env__numa_node */
> > int *numa_map;
> > int nr_numa_map;
> > +
> > + /* For real clock time refference. */
>
> typo: reference

ok

SNIP

> > + else {
> > + strftime(date, sizeof(date), "%F %T", &ltime);
> > + scnprintf(tstr, sizeof(tstr), "%s.%06d",
> > + date, (int) tod_ns.tv_usec);
> > + }
> > +
> > + fprintf(fp, "# clockid: %s (%u)\n", clockid_name(clockid), clockid);
> > + fprintf(fp, "# reference time: %s = %ld.%06d (TOD) = %ld.%ld (%s)\n",
>
> Shouldn't the last one be %ld.%09ld?

sure, why not

thanks,
jirka