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

From: Alexey Budankov
Date: Mon Oct 08 2018 - 14:13:20 EST



Hi,

On 08.10.2018 20:42, Arnaldo Carvalho de Melo wrote:
> 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?

Right. Let me take care of all that.

Thanks!
Alexey

>
> I'm removing the patch till this gets sorted out,
>
> Thanks,
>
> - Arnaldo
>