Re: [PATCH 3/3] tools/power turbostat: allow turbostat to work when aperf is not available
From: David Arcari
Date: Tue Dec 02 2025 - 07:55:19 EST
On 12/1/25 3:11 PM, Len Brown wrote:
Something like this?
Yes - this works. It's actually nice and clean and actually mitigates
the need for patch 0001. Clearly an improvement over my patch 3.
How would you like to proceed? I could resubmit a single v2 patch (with
an appropriate explanation).
I'd rather not attempt to solve the retry issue. It's really a second
order issue and I don't think I'm the appropriate person to do that work.
-DA
diff --git a/tools/power/x86/turbostat/turbostat.c
b/tools/power/x86/turbostat/turbostat.c
index 5bc47ad5da09..4a847e7e9c65 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -8530,7 +8530,7 @@ void rapl_perf_init(void)
/* Assumes msr_counter_info is populated */
static int has_amperf_access(void)
{
- return msr_counter_arch_infos[MSR_ARCH_INFO_APERF_INDEX].present &&
+ return has_aperf &&
msr_counter_arch_infos[MSR_ARCH_INFO_APERF_INDEX].present &&
msr_counter_arch_infos[MSR_ARCH_INFO_MPERF_INDEX].present;
}
On Mon, Dec 1, 2025 at 2:53 PM Len Brown <lenb@xxxxxxxxxx> wrote:
...add_msr_perf_counter() returns -1
good. and then add_msr_counter() succeeds because...
rdmsr returns zero for MSR_IA32_APERF and MSR_IA32_MPERF.
Your patch is a good suggestion -- though it checks for APERF only and
not for MPERF.
We already ran CPUID and cleared has_aperf, so I'm thinking we should
be heading this off earlier. Let me send you a test patch later today.
thanks,
Len Brown, Intel Open Source Technology Center