Skip to content

Commit 951845d

Browse files
committed
tools/power turbostat: Validate APERF access for VMWARE
VMWARE correctly enumerates lack of APERF and MPERF in CPUID, but turbostat didn't consult that before attempting to access them. Since VMWARE allows access, but always returns 0, turbostat got confusd into an infinite reset loop. Head this off by listening to CPUID.6.APERF_MPERF (and rename the existing variable to make this more clear) Reported-by: David Arcari <darcari@redhat.com> Tested-by: David Arcari <darcari@redhat.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 68769a0 commit 951845d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ unsigned int summary_only;
497497
unsigned int list_header_only;
498498
unsigned int dump_only;
499499
unsigned int force_load;
500-
unsigned int has_aperf;
500+
unsigned int cpuid_has_aperf_mperf;
501501
unsigned int has_aperf_access;
502502
unsigned int has_epb;
503503
unsigned int has_turbo;
@@ -8404,7 +8404,7 @@ void linux_perf_init(void)
84048404
if (access("/proc/sys/kernel/perf_event_paranoid", F_OK))
84058405
return;
84068406

8407-
if (BIC_IS_ENABLED(BIC_IPC) && has_aperf) {
8407+
if (BIC_IS_ENABLED(BIC_IPC) && cpuid_has_aperf_mperf) {
84088408
fd_instr_count_percpu = calloc(topo.max_cpu_num + 1, sizeof(int));
84098409
if (fd_instr_count_percpu == NULL)
84108410
err(-1, "calloc fd_instr_count_percpu");
@@ -8524,7 +8524,7 @@ void rapl_perf_init(void)
85248524
/* Assumes msr_counter_info is populated */
85258525
static int has_amperf_access(void)
85268526
{
8527-
return msr_counter_arch_infos[MSR_ARCH_INFO_APERF_INDEX].present &&
8527+
return cpuid_has_aperf_mperf && msr_counter_arch_infos[MSR_ARCH_INFO_APERF_INDEX].present &&
85288528
msr_counter_arch_infos[MSR_ARCH_INFO_MPERF_INDEX].present;
85298529
}
85308530

@@ -8936,7 +8936,7 @@ void process_cpuid()
89368936
*/
89378937

89388938
__cpuid(0x6, eax, ebx, ecx, edx);
8939-
has_aperf = ecx & (1 << 0);
8939+
cpuid_has_aperf_mperf = ecx & (1 << 0);
89408940
do_dts = eax & (1 << 0);
89418941
if (do_dts)
89428942
BIC_PRESENT(BIC_CoreTmp);
@@ -8954,7 +8954,7 @@ void process_cpuid()
89548954
if (!quiet)
89558955
fprintf(outf, "CPUID(6): %sAPERF, %sTURBO, %sDTS, %sPTM, %sHWP, "
89568956
"%sHWPnotify, %sHWPwindow, %sHWPepp, %sHWPpkg, %sEPB\n",
8957-
has_aperf ? "" : "No-",
8957+
cpuid_has_aperf_mperf ? "" : "No-",
89588958
has_turbo ? "" : "No-",
89598959
do_dts ? "" : "No-",
89608960
do_ptm ? "" : "No-",
@@ -9032,7 +9032,7 @@ void process_cpuid()
90329032
base_mhz, max_mhz, bus_mhz);
90339033
}
90349034

9035-
if (has_aperf)
9035+
if (cpuid_has_aperf_mperf)
90369036
aperf_mperf_multiplier = platform->need_perf_multiplier ? 1024 : 1;
90379037

90389038
BIC_PRESENT(BIC_IRQ);
@@ -10231,7 +10231,7 @@ int get_and_dump_counters(void)
1023110231

1023210232
void print_version()
1023310233
{
10234-
fprintf(outf, "turbostat version 2025.12.01 - Len Brown <lenb@kernel.org>\n");
10234+
fprintf(outf, "turbostat version 2025.12.02 - Len Brown <lenb@kernel.org>\n");
1023510235
}
1023610236

1023710237
#define COMMAND_LINE_SIZE 2048

0 commit comments

Comments
 (0)