From ecdcad9ec544c3c1c20a39c0766be13ead3e6c2c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 11 Dec 2008 11:27:49 +0000 Subject: [PATCH] cpufreq: Short path avoiding IPI in critical fast path. Signed-off-by: Liu, Jinsong Signed-off-by: Keir Fraser --- xen/arch/x86/acpi/cpufreq/cpufreq.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufreq/cpufreq.c index a66dc6dc7f..7f996e4d6f 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -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) -- 2.30.2