Re: [PATCH] perf metrics: Add literal for system TSC frequency

From: Ian Rogers
Date: Thu Feb 03 2022 - 02:58:21 EST


On Wed, Feb 2, 2022 at 7:59 PM Andi Kleen <ak@xxxxxxxxxxxxxxx> wrote:
>
>
> On 2/2/2022 5:07 PM, Ian Rogers wrote:
> > Such a literal is useful to calculate things like the average frequency
> > [1]. The TSC frequency isn't exposed by sysfs although some experimental
> > drivers look to add it [2]. This change computes the value using the
> > frequency in /proc/cpuinfo which is accruate at least on Intel
> > processors.
>
> FWIW the information in /proc/cpuinfo is going away.
>
> You should really use CPUID for this, which has a new leaf for this.
> Unfortunately there
>
> were a few systems were it was inaccurate, but I suppose you could still
> prefer /proc/cpuinfo
>
> Also your method will not work when the metrics are used through perf
> stat report or perf script
>
> and run on another system. For the perf script case there is support for
> putting the TSC into
>
> perf.data (that is needed for PT), but the header is not dumped by
> default unfortunately.
>
> So likely you would need some new mechanism for that.

Thanks Andi,

yep metrics with perf stat record are broken on a number of fronts and
this will be another that will need a fix. It looks like the cpuid
approach won't work pre-Skylake so sysfs could act as a fallback, but
I don't have an ETA on when that will be available. We could have
additional warnings when reading /proc/cpuinfo fails. Wdyt?

Thanks,
Ian

> -Andi
>