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

From: Andi Kleen
Date: Wed Feb 02 2022 - 23:00:03 EST



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.

-Andi