[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/cpufreq: Rework APERF/MPERF handling



commit 4dd16c44152f57f2f96d32e9a06fb7e259cde31b
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Nov 12 16:28:24 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Nov 29 13:53:05 2021 +0000

    x86/cpufreq: Rework APERF/MPERF handling
    
    Currently, each feature_detect() (called on CPU add) hook for both cpufreq
    drivers duplicates cpu_has_aperfmperf in a per-cpu datastructure, and edits
    cpufreq_driver.getavg to point at get_measured_perf().
    
    As all parts of this are vendor-neutral, drop the function pointer and
    duplicated boolean, and call get_measured_perf() directly.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/acpi/cpufreq/cpufreq.c  | 8 +-------
 xen/arch/x86/acpi/cpufreq/powernow.c | 6 ------
 xen/drivers/cpufreq/utility.c        | 9 +++------
 xen/include/acpi/cpufreq/cpufreq.h   | 2 --
 4 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c 
b/xen/arch/x86/acpi/cpufreq/cpufreq.c
index df9747e0b6..029c9398c4 100644
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c
@@ -275,7 +275,7 @@ unsigned int get_measured_perf(unsigned int cpu, unsigned 
int flag)
         return 0;
 
     policy = per_cpu(cpufreq_cpu_policy, cpu);
-    if (!policy || !policy->aperf_mperf)
+    if ( !policy || !cpu_has_aperfmperf )
         return 0;
 
     switch (flag)
@@ -345,12 +345,6 @@ static void feature_detect(void *info)
     struct cpufreq_policy *policy = info;
     unsigned int eax;
 
-    if ( cpu_has_aperfmperf )
-    {
-        policy->aperf_mperf = 1;
-        cpufreq_driver.getavg = get_measured_perf;
-    }
-
     eax = cpuid_eax(6);
     if (eax & 0x2) {
         policy->turbo = CPUFREQ_TURBO_ENABLED;
diff --git a/xen/arch/x86/acpi/cpufreq/powernow.c 
b/xen/arch/x86/acpi/cpufreq/powernow.c
index dfd96b9216..97a883e7a7 100644
--- a/xen/arch/x86/acpi/cpufreq/powernow.c
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c
@@ -205,12 +205,6 @@ static void feature_detect(void *info)
     struct cpufreq_policy *policy = info;
     unsigned int edx;
 
-    if ( cpu_has_aperfmperf )
-    {
-        policy->aperf_mperf = 1;
-        cpufreq_driver.getavg = get_measured_perf;
-    }
-
     edx = cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES);
     if ((edx & CPB_CAPABLE) == CPB_CAPABLE) {
         policy->turbo = CPUFREQ_TURBO_ENABLED;
diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c
index b93895d4dd..9eb7ecedcd 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -381,12 +381,9 @@ int cpufreq_driver_getavg(unsigned int cpu, unsigned int 
flag)
     if (!cpu_online(cpu) || !(policy = per_cpu(cpufreq_cpu_policy, cpu)))
         return 0;
 
-    if (cpufreq_driver.getavg)
-    {
-        freq_avg = cpufreq_driver.getavg(cpu, flag);
-        if (freq_avg > 0)
-            return freq_avg;
-    }
+    freq_avg = get_measured_perf(cpu, flag);
+    if ( freq_avg > 0 )
+        return freq_avg;
 
     return policy->cur;
 }
diff --git a/xen/include/acpi/cpufreq/cpufreq.h 
b/xen/include/acpi/cpufreq/cpufreq.h
index e88b20bfed..4958d3f7d3 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -72,7 +72,6 @@ struct cpufreq_policy {
     s8                  turbo;  /* tristate flag: 0 for unsupported
                                  * -1 for disable, 1 for enabled
                                  * See CPUFREQ_TURBO_* below for defines */
-    bool_t              aperf_mperf; /* CPU has APERF/MPERF MSRs */
 };
 DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy);
 
@@ -162,7 +161,6 @@ struct cpufreq_driver {
                      unsigned int target_freq,
                      unsigned int relation);
     unsigned int    (*get)(unsigned int cpu);
-    unsigned int    (*getavg)(unsigned int cpu, unsigned int flag);
     int    (*exit)(struct cpufreq_policy *policy);
 };
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.