Re: [PATCH 02/11] perf/x86: Add support for TSC as a perf event clock

From: Adrian Hunter
Date: Wed Feb 09 2022 - 08:39:40 EST


On 09/02/2022 15:11, Peter Zijlstra wrote:
> On Wed, Feb 09, 2022 at 10:49:20AM +0200, Adrian Hunter wrote:
>> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
>> index 82858b697c05..150d2b70a41f 100644
>> --- a/include/uapi/linux/perf_event.h
>> +++ b/include/uapi/linux/perf_event.h
>> @@ -290,6 +290,14 @@ enum {
>> PERF_TXN_ABORT_SHIFT = 32,
>> };
>>
>> +/*
>> + * If supported, clockid value to select an architecture dependent hardware
>> + * clock. Note this means the unit of time is ticks not nanoseconds.
>> + * On x86, this is provided by the rdtsc instruction, and is not
>> + * paravirtualized.
>> + */
>> +#define CLOCK_PERF_HW_CLOCK 0x10000000
>
> This steps on the clockid_t space; are we good with that?
>
> At some point there was talk of dynamic clock ids, that would complicate
> things more than they are today.

There are 16 clock IDs at the moment and perf only supports a few of them.

If there were a conflict in the future, then an attribute bit would be needed
to differentiate the 2 cases: standard clock IDs vs non-standard "perf" clock IDs.
An alternative would be to add that attribute bit now.