cpufreq: Short path avoiding IPI in critical fast path.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 11 Dec 2008 11:27:49 +0000 (11:27 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 11 Dec 2008 11:27:49 +0000 (11:27 +0000)
Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/acpi/cpufreq/cpufreq.c

index a66dc6dc7fb24741652581f88ff58c5f61ef58b4..7f996e4d6fab38cf00665f1004b9b2bfa5440efe 100644 (file)
@@ -255,17 +255,27 @@ static void  __get_measured_perf(void *perf_percent)
 
 static unsigned int get_measured_perf(unsigned int cpu)
 {
-    unsigned int retval, perf_percent;
+    struct cpufreq_policy *policy;
+    unsigned int perf_percent;
     cpumask_t cpumask;
 
     if (!cpu_online(cpu))
         return 0;
 
-    cpumask = cpumask_of_cpu(cpu);
-    on_selected_cpus(cpumask, __get_measured_perf, (void *)&perf_percent,0,1);
+    policy = cpufreq_cpu_policy[cpu];
+    if (!policy)
+        return 0;
+
+    /* Usually we take the short path (no IPI) for the sake of performance. */
+    if (cpu == smp_processor_id()) {
+        __get_measured_perf((void *)&perf_percent);
+    } else {
+        cpumask = cpumask_of_cpu(cpu);
+        on_selected_cpus(cpumask, __get_measured_perf, 
+                        (void *)&perf_percent,0,1);
+    }
 
-    retval = drv_data[cpu]->max_freq * perf_percent / 100;
-    return retval;
+    return drv_data[cpu]->max_freq * perf_percent / 100;
 }
 
 static unsigned int get_cur_freq_on_cpu(unsigned int cpu)