Re: [PATCH v3] perf record: encode -k clockid frequency into Perf trace

From: Arnaldo Carvalho de Melo
Date: Mon Oct 08 2018 - 13:42:18 EST


Em Wed, Oct 03, 2018 at 07:57:12PM +0300, Alexey Budankov escreveu:
>
> Store -k clockid frequency into Perf trace to enable timestamps
> derived metrics conversion into wall clock time on reporting stage.

<SNIP>

> +++ b/tools/perf/util/env.h
> @@ -63,6 +63,7 @@ struct perf_env {
> struct numa_node *numa_nodes;
> struct memory_node *memory_nodes;
> unsigned long long memory_bsize;
> + size_t clockid_res_ns;
> };
>
> extern struct perf_env perf_env;
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 1ec1d9bc2d63..4ce5339158f7 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -1034,6 +1034,13 @@ static int write_auxtrace(struct feat_fd *ff,
> return err;
> }
>
> +static int write_clockid(struct feat_fd *ff,
> + struct perf_evlist *evlist __maybe_unused)
> +{
> + return do_write(ff, &ff->ph->env.clockid_res_ns,
> + sizeof(ff->ph->env.clockid_res_ns));
> +}
> +

Is sizeof(size_t) the same everywhere? I think you should encode this
always as a u64, read it, assign it to a temp u64 var, write the u64 to
the perf.data header, read it using do_read_u64, that will take care of
endianness, then set it to the size_t in the ff->ph->env.clockid_res_ns,
right?

I'm removing the patch till this gets sorted out,

Thanks,

- Arnaldo