ia64/xen-unstable

changeset 19413:0fc0de02856a

Deliver cpufreq actual average freq to libxc interface

Calculate cpu actual average freq according to aperf and mperf MSR and
then deliver to libxc interface

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Mar 20 08:48:57 2009 +0000 (2009-03-20)
parents 532e25fda238
children 2a373e32b04d
files tools/libxc/xc_pm.c tools/libxc/xenctrl.h xen/drivers/acpi/pmstat.c xen/include/public/sysctl.h
line diff
     1.1 --- a/tools/libxc/xc_pm.c	Fri Mar 20 08:48:17 2009 +0000
     1.2 +++ b/tools/libxc/xc_pm.c	Fri Mar 20 08:48:57 2009 +0000
     1.3 @@ -307,6 +307,24 @@ int xc_set_cpufreq_para(int xc_handle, i
     1.4      return xc_sysctl(xc_handle, &sysctl);
     1.5  }
     1.6  
     1.7 +int xc_get_cpufreq_avgfreq(int xc_handle, int cpuid, int *avg_freq)
     1.8 +{
     1.9 +    int ret = 0;
    1.10 +    DECLARE_SYSCTL;
    1.11 +
    1.12 +    if ( (xc_handle < 0) || (!avg_freq) )
    1.13 +        return -EINVAL;
    1.14 +
    1.15 +    sysctl.cmd = XEN_SYSCTL_pm_op;
    1.16 +    sysctl.u.pm_op.cmd = GET_CPUFREQ_AVGFREQ;
    1.17 +    sysctl.u.pm_op.cpuid = cpuid;
    1.18 +    ret = xc_sysctl(xc_handle, &sysctl);
    1.19 +
    1.20 +    *avg_freq = sysctl.u.pm_op.get_avgfreq;
    1.21 +
    1.22 +    return ret;
    1.23 +}
    1.24 +
    1.25  int xc_get_cputopo(int xc_handle, struct xc_get_cputopo *info)
    1.26  {
    1.27      int rc;
     2.1 --- a/tools/libxc/xenctrl.h	Fri Mar 20 08:48:17 2009 +0000
     2.2 +++ b/tools/libxc/xenctrl.h	Fri Mar 20 08:48:57 2009 +0000
     2.3 @@ -1242,6 +1242,7 @@ int xc_get_cpufreq_para(int xc_handle, i
     2.4  int xc_set_cpufreq_gov(int xc_handle, int cpuid, char *govname);
     2.5  int xc_set_cpufreq_para(int xc_handle, int cpuid,
     2.6                          int ctrl_type, int ctrl_value);
     2.7 +int xc_get_cpufreq_avgfreq(int xc_handle, int cpuid, int *avg_freq);
     2.8  
     2.9  struct xc_get_cputopo {
    2.10       /* IN: maximum addressable entry in
     3.1 --- a/xen/drivers/acpi/pmstat.c	Fri Mar 20 08:48:17 2009 +0000
     3.2 +++ b/xen/drivers/acpi/pmstat.c	Fri Mar 20 08:48:57 2009 +0000
     3.3 @@ -409,6 +409,16 @@ static int set_cpufreq_para(struct xen_s
     3.4      return ret;
     3.5  }
     3.6  
     3.7 +static int get_cpufreq_avgfreq(struct xen_sysctl_pm_op *op)
     3.8 +{
     3.9 +    if ( !op || !cpu_online(op->cpuid) )
    3.10 +        return -EINVAL;
    3.11 +
    3.12 +    op->get_avgfreq = cpufreq_driver_getavg(op->cpuid, USR_GETAVG);
    3.13 +
    3.14 +    return 0;
    3.15 +}
    3.16 +
    3.17  static int get_cputopo (struct xen_sysctl_pm_op *op)
    3.18  {
    3.19      uint32_t i, nr_cpus;
    3.20 @@ -494,6 +504,12 @@ int do_pm_op(struct xen_sysctl_pm_op *op
    3.21          break;
    3.22      }
    3.23  
    3.24 +    case GET_CPUFREQ_AVGFREQ:
    3.25 +    {
    3.26 +        ret = get_cpufreq_avgfreq(op);
    3.27 +        break;
    3.28 +    }
    3.29 +
    3.30      case XEN_SYSCTL_pm_op_get_cputopo:
    3.31      {
    3.32          ret = get_cputopo(op);
     4.1 --- a/xen/include/public/sysctl.h	Fri Mar 20 08:48:17 2009 +0000
     4.2 +++ b/xen/include/public/sysctl.h	Fri Mar 20 08:48:57 2009 +0000
     4.3 @@ -376,6 +376,7 @@ struct xen_sysctl_pm_op {
     4.4      #define GET_CPUFREQ_PARA           (CPUFREQ_PARA | 0x01)
     4.5      #define SET_CPUFREQ_GOV            (CPUFREQ_PARA | 0x02)
     4.6      #define SET_CPUFREQ_PARA           (CPUFREQ_PARA | 0x03)
     4.7 +    #define GET_CPUFREQ_AVGFREQ        (CPUFREQ_PARA | 0x04)
     4.8  
     4.9      /* get CPU topology */
    4.10      #define XEN_SYSCTL_pm_op_get_cputopo  0x20
    4.11 @@ -386,6 +387,7 @@ struct xen_sysctl_pm_op {
    4.12          struct xen_get_cpufreq_para get_para;
    4.13          struct xen_set_cpufreq_gov  set_gov;
    4.14          struct xen_set_cpufreq_para set_para;
    4.15 +        uint64_t get_avgfreq;
    4.16          struct xen_get_cputopo      get_topo;
    4.17      };
    4.18  };