ia64/xen-unstable

changeset 18101:b896b39470f0

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>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 18 11:24:13 2008 +0100 (2008-07-18)
parents 48be9885d341
children 7f766b4a170b
files xen/arch/x86/acpi/cpufreq/cpufreq.c
line diff
     1.1 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c	Fri Jul 18 11:23:25 2008 +0100
     1.2 +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c	Fri Jul 18 11:24:13 2008 +0100
     1.3 @@ -237,9 +237,9 @@ static u32 get_cur_val(cpumask_t mask)
     1.4   * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and
     1.5   * no meaning should be associated with absolute values of these MSRs.
     1.6   */
     1.7 -/* FIXME: handle query on non-current cpu later */
     1.8 -static unsigned int get_measured_perf(unsigned int cpu)
     1.9 +static void  __get_measured_perf(void *perf_percent)
    1.10  {
    1.11 +    unsigned int *ratio = perf_percent;
    1.12      union {
    1.13          struct {
    1.14              uint32_t lo;
    1.15 @@ -248,9 +248,6 @@ static unsigned int get_measured_perf(un
    1.16          uint64_t whole;
    1.17      } aperf_cur, mperf_cur;
    1.18  
    1.19 -    unsigned int perf_percent;
    1.20 -    unsigned int retval;
    1.21 -
    1.22      rdmsr(MSR_IA32_APERF, aperf_cur.split.lo, aperf_cur.split.hi);
    1.23      rdmsr(MSR_IA32_MPERF, mperf_cur.split.lo, mperf_cur.split.hi);
    1.24  
    1.25 @@ -264,10 +261,21 @@ static unsigned int get_measured_perf(un
    1.26      }
    1.27  
    1.28      if (aperf_cur.whole && mperf_cur.whole)
    1.29 -        perf_percent = (aperf_cur.whole * 100) / mperf_cur.whole;
    1.30 +        *ratio = (aperf_cur.whole * 100) / mperf_cur.whole;
    1.31      else
    1.32 -        perf_percent = 0;
    1.33 +        *ratio = 0;
    1.34 +}
    1.35  
    1.36 +static unsigned int get_measured_perf(unsigned int cpu)
    1.37 +{
    1.38 +    unsigned int retval, perf_percent;
    1.39 +    cpumask_t cpumask;
    1.40 +
    1.41 +    if (!cpu_online(cpu))
    1.42 +        return 0;
    1.43 +
    1.44 +    cpumask = cpumask_of_cpu(cpu);
    1.45 +    on_selected_cpus(cpumask, __get_measured_perf, (void *)&perf_percent,0,1);
    1.46  
    1.47      retval = drv_data[cpu]->max_freq * perf_percent / 100;
    1.48      return retval;