Re: [PATCH V5 4/8] perf/x86/intel/uncore: add new data structures for free running counters

From: Peter Zijlstra
Date: Thu Jan 18 2018 - 08:33:01 EST


On Mon, Jan 15, 2018 at 10:57:05AM -0800, kan.liang@xxxxxxxxx wrote:
> From: Kan Liang <Kan.liang@xxxxxxxxx>
>
> There are a number of free running counters introduced for uncore, which
> provide highly valuable information to a wide array of customers.
> For example, Skylake Server has IIO free running counters to collect
> Input/Output x BW/Utilization.
> The precious generic counters could be saved to collect other customer
> interested data.
>
> The free running counter is read-only and always active. Current generic
> uncore code does not support this kind of counters.
>
> Introduce a new index to indicate the free running counters. Only one
> index is enough for all free running counters. Because the free running
> countes are always active, and the event and free running counter are
> always 1:1 mapped. It does not need extra index to indicate the assigned
> counter.
>
> Introduce some rules to encode the event for free running counters.
> - The event for free running counter has the same event code 0xff as the
> event for fixed counter.
> - The umask of the event starts from 0x10. The umask which is less than
> 0x10 is reserved for the event of fixed counter.
> - The free running counters can be divided into different types
> according to the MSR location, bit width or definition. The start
> point of the umask for different type has 0x10 offset.
> For example, there are three types of IIO free running counters on
> Skylake server, IO CLOCKS counters, BANDWIDTH counters and UTILIZATION
> counters.
> The event code for all free running counters is 0xff.
> 'ioclk' is the first counter of IO CLOCKS. IO CLOCKS is the first type
> of free running counters, which umask starts from 0x10.
> So 'ioclk' is encoded as event=0xff,umask=0x10
> 'bw_in_port2' is the third counter of BANDWIDTH counters. BANDWIDTH is
> the second type which umask starts from 0x20.
> So 'bw_in_port2' is encoded as event=0xff,umask=0x22.
>
> Introduce a new data structure to store free running counters related
> information for each type. It includes the number of counters, bit
> width, base address, offset between counters and offset between boxes.
>
> Introduce several inline helpers to check index for fixed counter and
> free running counter, validate free running counter event, and retrieve
> the free running counter information according to box and event.

Sorry, none of this makes any sense, what?

WTH would all free running counters, which presumably count different
things, have the same event code ?

And whats the hackery with the umask do?

Please rewrite this in comprehensible form and also give rationale for
the various choices.