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

[Xen-devel] [PATCH] x86/cpufreq: fix turbo mode detection



acpi_cpufreq_cpu_init() does generally not run on the CPU the policy
it deals with is related to, hence using cpuid() directly works only
as long as all CPUs in the system are identical (which admittedly
is commonly the case).

Also fix a minor glitch in xenpm, which I noticed while looking into
the original inconsistencies on one of my systems.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2010-05-04.orig/tools/misc/xenpm.c  2010-04-14 14:05:14.000000000 +0200
+++ 2010-05-04/tools/misc/xenpm.c       2010-05-06 13:37:30.000000000 +0200
@@ -499,10 +499,7 @@ static void print_cpufreq_para(int cpuid
 
     printf("affected_cpus        :");
     for ( i = 0; i < p_cpufreq->cpu_num; i++ )
-        if ( i == cpuid )
-            printf(" *%d", p_cpufreq->affected_cpus[i]);
-        else
-            printf(" %d", p_cpufreq->affected_cpus[i]);
+        printf(" %d", p_cpufreq->affected_cpus[i]);
     printf("\n");
 
     printf("cpuinfo frequency    : max [%u] min [%u] cur [%u]\n",
--- 2010-05-04.orig/xen/arch/x86/acpi/cpufreq/cpufreq.c 2010-04-12 
11:28:20.000000000 +0200
+++ 2010-05-04/xen/arch/x86/acpi/cpufreq/cpufreq.c      2010-05-06 
13:24:41.000000000 +0200
@@ -377,6 +377,23 @@ static unsigned int get_cur_freq_on_cpu(
     return freq;
 }
 
+static void feature_detect(void *info)
+{
+    struct cpufreq_policy *policy = info;
+    unsigned int eax, ecx;
+
+    ecx = cpuid_ecx(6);
+    if (ecx & CPUID_6_ECX_APERFMPERF_CAPABILITY)
+        acpi_cpufreq_driver.getavg = get_measured_perf;
+    eax = cpuid_eax(6);
+    if (eax & 0x2) {
+        policy->turbo = CPUFREQ_TURBO_ENABLED;
+        if (cpufreq_verbose)
+            printk(XENLOG_INFO "CPU%u: Turbo Mode detected and enabled\n",
+                   smp_processor_id());
+    }
+}
+
 static unsigned int check_freqs(cpumask_t mask, unsigned int freq,
                                 struct acpi_cpufreq_data *data)
 {
@@ -615,18 +632,8 @@ acpi_cpufreq_cpu_init(struct cpufreq_pol
 
     /* Check for APERF/MPERF support in hardware
      * also check for boost support */
-    if (c->x86_vendor == X86_VENDOR_INTEL && c->cpuid_level >= 6) {
-        unsigned int ecx;
-        unsigned int eax;
-        ecx = cpuid_ecx(6);
-        if (ecx & CPUID_6_ECX_APERFMPERF_CAPABILITY)
-            acpi_cpufreq_driver.getavg = get_measured_perf;
-        eax = cpuid_eax(6);
-        if ( eax & 0x2 ) {
-            policy->turbo = CPUFREQ_TURBO_ENABLED;
-            printk(XENLOG_INFO "Turbo Mode detected and enabled!\n");
-        }
-    }
+    if (c->x86_vendor == X86_VENDOR_INTEL && c->cpuid_level >= 6)
+        on_selected_cpus(cpumask_of(cpu), feature_detect, policy, 1);
 
     /*
      * the first call to ->target() should result in us actually



Attachment: cpufreq-turbo-detect.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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