Don't use intel_cpus if APERF MSR isn't supported
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jaroslav Skarvada
Hi,
resending the patch which should allow PowerTOP to run on KVM and other VMs not fully supporting MSR
thanks & regards
Jaroslav
From f3b21d8aa4799db5b1ec41543fcae681c02a8c89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <[email protected]>
Date: Fri, 4 May 2018 23:36:46 +0200
Subject: [PATCH] Don't use intel_cpus if APERF MSR isn't supported
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The intel_cpus (class nhm_package) needs APERF MSR. This maybe problem on some virtual machines (e.g. KVM) where the APERF MSR is not implemented. On such VMs powertop exits with MSR read error and doesn't work. Previously, powertop worked in such cases (e.g. powertop-2.3). This patch adds check whether APERF MSR is supported, if not, intel_cpus is not used.
--- src/cpu/cpu.cpp | 6 +++--- src/cpu/intel_cpus.cpp | 6 ++++-- src/cpu/intel_cpus.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-)
src/cpu/cpu.cpp +3 -3
@@ -68,7 +68,7 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int char packagename[128]; if (strcmp(vendor, "GenuineIntel") == 0) if (family == 6) - if (is_supported_intel_cpu(model)) + if (is_supported_intel_cpu(model, cpu)) ret = new class nhm_package(model); if (!ret)
@@ -105,7 +105,7 @@ static class abstract_cpu * new_core(int core, int cpu, char * vendor, int famil if (strcmp(vendor, "GenuineIntel") == 0) if (family == 6) - if (is_supported_intel_cpu(model)) + if (is_supported_intel_cpu(model, cpu)) ret = new class nhm_core(model); if (!ret)
@@ -134,7 +134,7 @@ static class abstract_cpu * new_cpu(int number, char * vendor, int family, int m if (strcmp(vendor, "GenuineIntel") == 0) if (family == 6) - if (is_supported_intel_cpu(model)) + if (is_supported_intel_cpu(model, number)) ret = new class nhm_cpu; if (!ret)
src/cpu/intel_cpus.cpp +4 -2
@@ -77,13 +77,15 @@ static int intel_cpu_models[] = { static int intel_pstate_driver_loaded = -1; -int is_supported_intel_cpu(int model) +int is_supported_intel_cpu(int model, int cpu) { int i; + uint64_t msr; for (i = 0; intel_cpu_models[i] != 0; i++) if (model == intel_cpu_models[i]) - return 1; + if (cpu < 0 || read_msr(cpu, MSR_APERF, &msr) >= 0) + return 1; return 0; }
src/cpu/intel_cpus.h +1 -1
@@ -172,7 +172,7 @@ public: }; -int is_supported_intel_cpu (int model); +int is_supported_intel_cpu (int model,int cpu);int byt_has_ahci ();int is_intel_pstate_driver_loaded ();
Signature · 1 line
2.14.3