Mailing List Archive

[xen-unstable] x86: Fix APERF/MPERF query bug on non-current cpu
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1216376653 -3600
# Node ID b896b39470f0e1c957c82db30d915875b00c3776
# Parent 48be9885d341cc88128f2d3fa7e9d8ab0cf031f5
x86: Fix APERF/MPERF query bug on non-current cpu

Currently xen hypervisor cpufreq can only query APERF/MPERF on running
cpu, which will result in system broken when query on non-current
cpu. This patch fix the APERF/MPERF query bug on non-current cpu.

Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
xen/arch/x86/acpi/cpufreq/cpufreq.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)

diff -r 48be9885d341 -r b896b39470f0 xen/arch/x86/acpi/cpufreq/cpufreq.c
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c Fri Jul 18 11:23:25 2008 +0100
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c Fri Jul 18 11:24:13 2008 +0100
@@ -237,9 +237,9 @@ static u32 get_cur_val(cpumask_t mask)
* Only IA32_APERF/IA32_MPERF ratio is architecturally defined and
* no meaning should be associated with absolute values of these MSRs.
*/
-/* FIXME: handle query on non-current cpu later */
-static unsigned int get_measured_perf(unsigned int cpu)
-{
+static void __get_measured_perf(void *perf_percent)
+{
+ unsigned int *ratio = perf_percent;
union {
struct {
uint32_t lo;
@@ -248,9 +248,6 @@ static unsigned int get_measured_perf(un
uint64_t whole;
} aperf_cur, mperf_cur;

- unsigned int perf_percent;
- unsigned int retval;
-
rdmsr(MSR_IA32_APERF, aperf_cur.split.lo, aperf_cur.split.hi);
rdmsr(MSR_IA32_MPERF, mperf_cur.split.lo, mperf_cur.split.hi);

@@ -264,10 +261,21 @@ static unsigned int get_measured_perf(un
}

if (aperf_cur.whole && mperf_cur.whole)
- perf_percent = (aperf_cur.whole * 100) / mperf_cur.whole;
+ *ratio = (aperf_cur.whole * 100) / mperf_cur.whole;
else
- perf_percent = 0;
-
+ *ratio = 0;
+}
+
+static unsigned int get_measured_perf(unsigned int cpu)
+{
+ unsigned int retval, 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);

retval = drv_data[cpu]->max_freq * perf_percent / 100;
return retval;

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