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

From: Andi Kleen
Date: Fri May 27 2022 - 10:54:34 EST



On 5/27/2022 2:49 AM, Peter Zijlstra wrote:
On Thu, May 26, 2022 at 09:04:07PM -0700, 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 accurate at least on Intel
processors.

It would be better to use CPUID if available which is far more accurate. Also I believe newer Intel CPUs drop the frequency in the brand string.

BTW it also has the problem that if perf script is run on some other system to compute metrics it won't work.


This all seems bonghits inspired... and perf actually does expose the
tsc frequency. What do you think is in perf_event_mmap_page::time_* ?


That's not really available to perf stat, which is the primary metrics user.


-Andi