ia64/xen-unstable

changeset 19504:5966b71195b4

xenpm: Set scheduler vcpu_migration_delay by xenpm

Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Yang Xiaowei <xiaowei.yang@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 06 13:49:16 2009 +0100 (2009-04-06)
parents 1a7457bb1fdf
children bdbe5232b068
files tools/libxc/xc_pm.c tools/libxc/xenctrl.h tools/misc/xenpm.c xen/common/sched_credit.c xen/common/sysctl.c xen/drivers/acpi/pmstat.c xen/include/public/sysctl.h xen/include/xen/sched.h xen/include/xsm/xsm.h xen/xsm/dummy.c
line diff
     1.1 --- a/tools/libxc/xc_pm.c	Mon Apr 06 13:46:11 2009 +0100
     1.2 +++ b/tools/libxc/xc_pm.c	Mon Apr 06 13:49:16 2009 +0100
     1.3 @@ -362,6 +362,36 @@ int xc_set_sched_opt_smt(int xc_handle, 
     1.4     return rc;
     1.5  }
     1.6  
     1.7 +int xc_set_vcpu_migration_delay(int xc_handle, uint32_t value)
     1.8 +{
     1.9 +   int rc;
    1.10 +   DECLARE_SYSCTL;
    1.11 +
    1.12 +   sysctl.cmd = XEN_SYSCTL_pm_op;
    1.13 +   sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_vcpu_migration_delay;
    1.14 +   sysctl.u.pm_op.cpuid = 0;
    1.15 +   sysctl.u.pm_op.set_vcpu_migration_delay = value;
    1.16 +   rc = do_sysctl(xc_handle, &sysctl);
    1.17 +
    1.18 +   return rc;
    1.19 +}
    1.20 +
    1.21 +int xc_get_vcpu_migration_delay(int xc_handle, uint32_t *value)
    1.22 +{
    1.23 +   int rc;
    1.24 +   DECLARE_SYSCTL;
    1.25 +
    1.26 +   sysctl.cmd = XEN_SYSCTL_pm_op;
    1.27 +   sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_vcpu_migration_delay;
    1.28 +   sysctl.u.pm_op.cpuid = 0;
    1.29 +   rc = do_sysctl(xc_handle, &sysctl);
    1.30 +
    1.31 +   if (!rc && value)
    1.32 +       *value = sysctl.u.pm_op.get_vcpu_migration_delay;
    1.33 +
    1.34 +   return rc;
    1.35 +}
    1.36 +
    1.37  int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value)
    1.38  {
    1.39      int rc;
     2.1 --- a/tools/libxc/xenctrl.h	Mon Apr 06 13:46:11 2009 +0100
     2.2 +++ b/tools/libxc/xenctrl.h	Mon Apr 06 13:49:16 2009 +0100
     2.3 @@ -1261,6 +1261,8 @@ struct xc_get_cputopo {
     2.4  int xc_get_cputopo(int xc_handle, struct xc_get_cputopo *info);
     2.5  
     2.6  int xc_set_sched_opt_smt(int xc_handle, uint32_t value);
     2.7 +int xc_set_vcpu_migration_delay(int xc_handle, uint32_t value);
     2.8 +int xc_get_vcpu_migration_delay(int xc_handle, uint32_t *value);
     2.9  
    2.10  int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value);
    2.11  int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value);
     3.1 --- a/tools/misc/xenpm.c	Mon Apr 06 13:46:11 2009 +0100
     3.2 +++ b/tools/misc/xenpm.c	Mon Apr 06 13:49:16 2009 +0100
     3.3 @@ -57,6 +57,8 @@ void show_help(void)
     3.4              "                                     it is used in ondemand governor.\n"
     3.5              " get-cpu-topology                    get thread/core/socket topology info\n"
     3.6              " set-sched-smt           enable|disable enable/disable scheduler smt power saving\n"
     3.7 +            " set-vcpu-migration-delay      <num> set scheduler vcpu migration delay in us\n"
     3.8 +            " get-vcpu-migration-delay            get scheduler vcpu migration delay\n"
     3.9              " set-max-cstate        <num>         set the C-State limitation (<num> >= 0)\n"
    3.10              " start [seconds]                     start collect Cx/Px statistics,\n"
    3.11              "                                     output after CTRL-C or SIGINT or several seconds.\n"
    3.12 @@ -884,6 +886,54 @@ void set_sched_smt_func(int argc, char *
    3.13      return;
    3.14  }
    3.15  
    3.16 +void set_vcpu_migration_delay_func(int argc, char *argv[])
    3.17 +{
    3.18 +    int value;
    3.19 +    int rc;
    3.20 +
    3.21 +    if (argc != 1){
    3.22 +        show_help();
    3.23 +        exit(-1);
    3.24 +    }
    3.25 +
    3.26 +    value = atoi(argv[0]);
    3.27 +
    3.28 +    if (value < 0)
    3.29 +    {
    3.30 +        printf("Please try non-negative vcpu migration delay\n");
    3.31 +        exit(-1);
    3.32 +    }
    3.33 +
    3.34 +    rc = xc_set_vcpu_migration_delay(xc_fd, value);
    3.35 +    printf("%s to set vcpu migration delay to %d us\n",
    3.36 +                    rc? "Fail":"Succeed", value );
    3.37 +
    3.38 +    return;
    3.39 +}
    3.40 +
    3.41 +void get_vcpu_migration_delay_func(int argc, char *argv[])
    3.42 +{
    3.43 +    uint32_t value;
    3.44 +    int rc;
    3.45 +
    3.46 +    if (argc != 0){
    3.47 +        show_help();
    3.48 +        exit(-1);
    3.49 +    }
    3.50 +
    3.51 +    rc = xc_get_vcpu_migration_delay(xc_fd, &value);
    3.52 +    if (!rc)
    3.53 +    {
    3.54 +        printf("Schduler vcpu migration delay is %d us\n", value);
    3.55 +    }
    3.56 +    else
    3.57 +    {
    3.58 +        printf("Failed to get scheduler vcpu migration delay, errno=%d\n", errno);
    3.59 +    }
    3.60 +
    3.61 +    return;
    3.62 +}
    3.63 +
    3.64  void set_max_cstate_func(int argc, char *argv[])
    3.65  {
    3.66      int value, rc;
    3.67 @@ -918,6 +968,8 @@ struct {
    3.68      { "set-up-threshold", scaling_up_threshold_func },
    3.69      { "get-cpu-topology", cpu_topology_func},
    3.70      { "set-sched-smt", set_sched_smt_func},
    3.71 +    { "get-vcpu-migration-delay", get_vcpu_migration_delay_func},
    3.72 +    { "set-vcpu-migration-delay", set_vcpu_migration_delay_func},
    3.73      { "set-max-cstate", set_max_cstate_func},
    3.74  };
    3.75  
     4.1 --- a/xen/common/sched_credit.c	Mon Apr 06 13:46:11 2009 +0100
     4.2 +++ b/xen/common/sched_credit.c	Mon Apr 06 13:49:16 2009 +0100
     4.3 @@ -326,6 +326,16 @@ static inline void
     4.4  static unsigned int vcpu_migration_delay;
     4.5  integer_param("vcpu_migration_delay", vcpu_migration_delay);
     4.6  
     4.7 +void set_vcpu_migration_delay(unsigned int delay)
     4.8 +{
     4.9 +    vcpu_migration_delay = delay;
    4.10 +}
    4.11 +
    4.12 +unsigned int get_vcpu_migration_delay(void)
    4.13 +{
    4.14 +    return vcpu_migration_delay;
    4.15 +}
    4.16 +
    4.17  static inline int
    4.18  __csched_vcpu_is_cache_hot(struct vcpu *v)
    4.19  {
     5.1 --- a/xen/common/sysctl.c	Mon Apr 06 13:46:11 2009 +0100
     5.2 +++ b/xen/common/sysctl.c	Mon Apr 06 13:49:16 2009 +0100
     5.3 @@ -206,6 +206,10 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
     5.4  
     5.5      case XEN_SYSCTL_get_pmstat:
     5.6      {
     5.7 +        ret = xsm_get_pmstat();
     5.8 +        if ( ret )
     5.9 +            break;
    5.10 +
    5.11          ret = do_get_pm_info(&op->u.get_pmstat);
    5.12          if ( ret )
    5.13              break;
    5.14 @@ -220,6 +224,10 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
    5.15  
    5.16      case XEN_SYSCTL_pm_op:
    5.17      {
    5.18 +        ret = xsm_pm_op();
    5.19 +        if ( ret )
    5.20 +            break;
    5.21 +
    5.22          ret = do_pm_op(&op->u.pm_op);
    5.23          if ( ret && (ret != -EAGAIN) )
    5.24              break;
     6.1 --- a/xen/drivers/acpi/pmstat.c	Mon Apr 06 13:46:11 2009 +0100
     6.2 +++ b/xen/drivers/acpi/pmstat.c	Mon Apr 06 13:49:16 2009 +0100
     6.3 @@ -528,6 +528,18 @@ int do_pm_op(struct xen_sysctl_pm_op *op
     6.4          break;
     6.5      }
     6.6  
     6.7 +    case XEN_SYSCTL_pm_op_set_vcpu_migration_delay:
     6.8 +    {
     6.9 +        set_vcpu_migration_delay(op->set_vcpu_migration_delay);
    6.10 +        break;
    6.11 +    }
    6.12 +
    6.13 +    case XEN_SYSCTL_pm_op_get_vcpu_migration_delay:
    6.14 +    {
    6.15 +        op->get_vcpu_migration_delay = get_vcpu_migration_delay();
    6.16 +        break;
    6.17 +    }
    6.18 +
    6.19      case XEN_SYSCTL_pm_op_get_max_cstate:
    6.20      {
    6.21          op->get_max_cstate = acpi_get_cstate_limit();
     7.1 --- a/xen/include/public/sysctl.h	Mon Apr 06 13:46:11 2009 +0100
     7.2 +++ b/xen/include/public/sysctl.h	Mon Apr 06 13:49:16 2009 +0100
     7.3 @@ -386,6 +386,10 @@ struct xen_sysctl_pm_op {
     7.4      #define XEN_SYSCTL_pm_op_get_max_cstate       0x22
     7.5      #define XEN_SYSCTL_pm_op_set_max_cstate       0x23
     7.6  
     7.7 +    /* set scheduler migration cost value */
     7.8 +    #define XEN_SYSCTL_pm_op_set_vcpu_migration_delay   0x24
     7.9 +    #define XEN_SYSCTL_pm_op_get_vcpu_migration_delay   0x25
    7.10 +
    7.11      uint32_t cmd;
    7.12      uint32_t cpuid;
    7.13      union {
    7.14 @@ -397,6 +401,8 @@ struct xen_sysctl_pm_op {
    7.15          uint32_t                    set_sched_opt_smt;
    7.16          uint32_t                    get_max_cstate;
    7.17          uint32_t                    set_max_cstate;
    7.18 +        uint32_t                    get_vcpu_migration_delay;
    7.19 +        uint32_t                    set_vcpu_migration_delay;
    7.20      };
    7.21  };
    7.22  
     8.1 --- a/xen/include/xen/sched.h	Mon Apr 06 13:46:11 2009 +0100
     8.2 +++ b/xen/include/xen/sched.h	Mon Apr 06 13:49:16 2009 +0100
     8.3 @@ -552,6 +552,9 @@ uint64_t get_cpu_idle_time(unsigned int 
     8.4  #define is_hvm_vcpu(v)   (is_hvm_domain(v->domain))
     8.5  #define need_iommu(d)    ((d)->need_iommu && !(d)->is_hvm)
     8.6  
     8.7 +void set_vcpu_migration_delay(unsigned int delay);
     8.8 +unsigned int get_vcpu_migration_delay(void);
     8.9 +
    8.10  extern int sched_smt_power_savings;
    8.11  
    8.12  extern enum cpufreq_controller {
     9.1 --- a/xen/include/xsm/xsm.h	Mon Apr 06 13:46:11 2009 +0100
     9.2 +++ b/xen/include/xsm/xsm.h	Mon Apr 06 13:49:16 2009 +0100
     9.3 @@ -75,6 +75,8 @@ struct xsm_operations {
     9.4      int (*debug_keys) (void);
     9.5      int (*getcpuinfo) (void);
     9.6      int (*availheap) (void);
     9.7 +    int (*get_pmstat) (void);
     9.8 +    int (*pm_op) (void);
     9.9  
    9.10      int (*evtchn_unbound) (struct domain *d, struct evtchn *chn, domid_t id2);
    9.11      int (*evtchn_interdomain) (struct domain *d1, struct evtchn *chn1,
    9.12 @@ -282,6 +284,16 @@ static inline int xsm_getcpuinfo (void)
    9.13      return xsm_call(getcpuinfo());
    9.14  }
    9.15  
    9.16 +static inline int xsm_get_pmstat(void)
    9.17 +{
    9.18 +    return xsm_call(get_pmstat());
    9.19 +}
    9.20 +
    9.21 +static inline int xsm_pm_op(void)
    9.22 +{
    9.23 +    return xsm_call(pm_op());
    9.24 +}
    9.25 +
    9.26  static inline int xsm_evtchn_unbound (struct domain *d1, struct evtchn *chn,
    9.27                                                                      domid_t id2)
    9.28  {
    10.1 --- a/xen/xsm/dummy.c	Mon Apr 06 13:46:11 2009 +0100
    10.2 +++ b/xen/xsm/dummy.c	Mon Apr 06 13:49:16 2009 +0100
    10.3 @@ -134,6 +134,16 @@ static int dummy_getcpuinfo (void)
    10.4      return 0;
    10.5  }
    10.6  
    10.7 +static int dummy_get_pmstat (void)
    10.8 +{
    10.9 +    return 0;
   10.10 +}
   10.11 +
   10.12 +static int dummy_pm_op (void)
   10.13 +{
   10.14 +    return 0;
   10.15 +}
   10.16 +
   10.17  static int dummy_availheap (void)
   10.18  {
   10.19      return 0;