# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1239022156 -3600
# Node ID 5966b71195b4092f791fc20f028d5e24feda76ae
# Parent 1a7457bb1fdf3ca09840d5762cb77416eda5bd84
xenpm: Set scheduler vcpu_migration_delay by xenpm
Signed-off-by: Yu Ke <ke.yu@xxxxxxxxx>
Signed-off-by: Yang Xiaowei <xiaowei.yang@xxxxxxxxx>
---
tools/libxc/xc_pm.c | 30 +++++++++++++++++++++++++
tools/libxc/xenctrl.h | 2 +
tools/misc/xenpm.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
xen/common/sched_credit.c | 10 ++++++++
xen/common/sysctl.c | 8 ++++++
xen/drivers/acpi/pmstat.c | 12 ++++++++++
xen/include/public/sysctl.h | 6 +++++
xen/include/xen/sched.h | 3 ++
xen/include/xsm/xsm.h | 12 ++++++++++
xen/xsm/dummy.c | 10 ++++++++
10 files changed, 145 insertions(+)
diff -r 1a7457bb1fdf -r 5966b71195b4 tools/libxc/xc_pm.c
--- a/tools/libxc/xc_pm.c Mon Apr 06 13:46:11 2009 +0100
+++ b/tools/libxc/xc_pm.c Mon Apr 06 13:49:16 2009 +0100
@@ -362,6 +362,36 @@ int xc_set_sched_opt_smt(int xc_handle,
return rc;
}
+int xc_set_vcpu_migration_delay(int xc_handle, uint32_t value)
+{
+ int rc;
+ DECLARE_SYSCTL;
+
+ sysctl.cmd = XEN_SYSCTL_pm_op;
+ sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_vcpu_migration_delay;
+ sysctl.u.pm_op.cpuid = 0;
+ sysctl.u.pm_op.set_vcpu_migration_delay = value;
+ rc = do_sysctl(xc_handle, &sysctl);
+
+ return rc;
+}
+
+int xc_get_vcpu_migration_delay(int xc_handle, uint32_t *value)
+{
+ int rc;
+ DECLARE_SYSCTL;
+
+ sysctl.cmd = XEN_SYSCTL_pm_op;
+ sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_vcpu_migration_delay;
+ sysctl.u.pm_op.cpuid = 0;
+ rc = do_sysctl(xc_handle, &sysctl);
+
+ if (!rc && value)
+ *value = sysctl.u.pm_op.get_vcpu_migration_delay;
+
+ return rc;
+}
+
int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value)
{
int rc;
diff -r 1a7457bb1fdf -r 5966b71195b4 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Mon Apr 06 13:46:11 2009 +0100
+++ b/tools/libxc/xenctrl.h Mon Apr 06 13:49:16 2009 +0100
@@ -1261,6 +1261,8 @@ int xc_get_cputopo(int xc_handle, struct
int xc_get_cputopo(int xc_handle, struct xc_get_cputopo *info);
int xc_set_sched_opt_smt(int xc_handle, uint32_t value);
+int xc_set_vcpu_migration_delay(int xc_handle, uint32_t value);
+int xc_get_vcpu_migration_delay(int xc_handle, uint32_t *value);
int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value);
int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value);
diff -r 1a7457bb1fdf -r 5966b71195b4 tools/misc/xenpm.c
--- a/tools/misc/xenpm.c Mon Apr 06 13:46:11 2009 +0100
+++ b/tools/misc/xenpm.c Mon Apr 06 13:49:16 2009 +0100
@@ -57,6 +57,8 @@ void show_help(void)
" it is used in ondemand
governor.\n"
" get-cpu-topology get thread/core/socket
topology info\n"
" set-sched-smt enable|disable enable/disable scheduler
smt power saving\n"
+ " set-vcpu-migration-delay <num> set scheduler vcpu migration
delay in us\n"
+ " get-vcpu-migration-delay get scheduler vcpu migration
delay\n"
" set-max-cstate <num> set the C-State limitation
(<num> >= 0)\n"
" start [seconds] start collect Cx/Px
statistics,\n"
" output after CTRL-C or
SIGINT or several seconds.\n"
@@ -884,6 +886,54 @@ void set_sched_smt_func(int argc, char *
return;
}
+void set_vcpu_migration_delay_func(int argc, char *argv[])
+{
+ int value;
+ int rc;
+
+ if (argc != 1){
+ show_help();
+ exit(-1);
+ }
+
+ value = atoi(argv[0]);
+
+ if (value < 0)
+ {
+ printf("Please try non-negative vcpu migration delay\n");
+ exit(-1);
+ }
+
+ rc = xc_set_vcpu_migration_delay(xc_fd, value);
+ printf("%s to set vcpu migration delay to %d us\n",
+ rc? "Fail":"Succeed", value );
+
+ return;
+}
+
+void get_vcpu_migration_delay_func(int argc, char *argv[])
+{
+ uint32_t value;
+ int rc;
+
+ if (argc != 0){
+ show_help();
+ exit(-1);
+ }
+
+ rc = xc_get_vcpu_migration_delay(xc_fd, &value);
+ if (!rc)
+ {
+ printf("Schduler vcpu migration delay is %d us\n", value);
+ }
+ else
+ {
+ printf("Failed to get scheduler vcpu migration delay, errno=%d\n",
errno);
+ }
+
+ return;
+}
+
void set_max_cstate_func(int argc, char *argv[])
{
int value, rc;
@@ -918,6 +968,8 @@ struct {
{ "set-up-threshold", scaling_up_threshold_func },
{ "get-cpu-topology", cpu_topology_func},
{ "set-sched-smt", set_sched_smt_func},
+ { "get-vcpu-migration-delay", get_vcpu_migration_delay_func},
+ { "set-vcpu-migration-delay", set_vcpu_migration_delay_func},
{ "set-max-cstate", set_max_cstate_func},
};
diff -r 1a7457bb1fdf -r 5966b71195b4 xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Mon Apr 06 13:46:11 2009 +0100
+++ b/xen/common/sched_credit.c Mon Apr 06 13:49:16 2009 +0100
@@ -325,6 +325,16 @@ __csched_vcpu_check(struct vcpu *vc)
*/
static unsigned int vcpu_migration_delay;
integer_param("vcpu_migration_delay", vcpu_migration_delay);
+
+void set_vcpu_migration_delay(unsigned int delay)
+{
+ vcpu_migration_delay = delay;
+}
+
+unsigned int get_vcpu_migration_delay(void)
+{
+ return vcpu_migration_delay;
+}
static inline int
__csched_vcpu_is_cache_hot(struct vcpu *v)
diff -r 1a7457bb1fdf -r 5966b71195b4 xen/common/sysctl.c
--- a/xen/common/sysctl.c Mon Apr 06 13:46:11 2009 +0100
+++ b/xen/common/sysctl.c Mon Apr 06 13:49:16 2009 +0100
@@ -206,6 +206,10 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
case XEN_SYSCTL_get_pmstat:
{
+ ret = xsm_get_pmstat();
+ if ( ret )
+ break;
+
ret = do_get_pm_info(&op->u.get_pmstat);
if ( ret )
break;
@@ -220,6 +224,10 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
case XEN_SYSCTL_pm_op:
{
+ ret = xsm_pm_op();
+ if ( ret )
+ break;
+
ret = do_pm_op(&op->u.pm_op);
if ( ret && (ret != -EAGAIN) )
break;
diff -r 1a7457bb1fdf -r 5966b71195b4 xen/drivers/acpi/pmstat.c
--- a/xen/drivers/acpi/pmstat.c Mon Apr 06 13:46:11 2009 +0100
+++ b/xen/drivers/acpi/pmstat.c Mon Apr 06 13:49:16 2009 +0100
@@ -528,6 +528,18 @@ int do_pm_op(struct xen_sysctl_pm_op *op
break;
}
+ case XEN_SYSCTL_pm_op_set_vcpu_migration_delay:
+ {
+ set_vcpu_migration_delay(op->set_vcpu_migration_delay);
+ break;
+ }
+
+ case XEN_SYSCTL_pm_op_get_vcpu_migration_delay:
+ {
+ op->get_vcpu_migration_delay = get_vcpu_migration_delay();
+ break;
+ }
+
case XEN_SYSCTL_pm_op_get_max_cstate:
{
op->get_max_cstate = acpi_get_cstate_limit();
diff -r 1a7457bb1fdf -r 5966b71195b4 xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h Mon Apr 06 13:46:11 2009 +0100
+++ b/xen/include/public/sysctl.h Mon Apr 06 13:49:16 2009 +0100
@@ -386,6 +386,10 @@ struct xen_sysctl_pm_op {
#define XEN_SYSCTL_pm_op_get_max_cstate 0x22
#define XEN_SYSCTL_pm_op_set_max_cstate 0x23
+ /* set scheduler migration cost value */
+ #define XEN_SYSCTL_pm_op_set_vcpu_migration_delay 0x24
+ #define XEN_SYSCTL_pm_op_get_vcpu_migration_delay 0x25
+
uint32_t cmd;
uint32_t cpuid;
union {
@@ -397,6 +401,8 @@ struct xen_sysctl_pm_op {
uint32_t set_sched_opt_smt;
uint32_t get_max_cstate;
uint32_t set_max_cstate;
+ uint32_t get_vcpu_migration_delay;
+ uint32_t set_vcpu_migration_delay;
};
};
diff -r 1a7457bb1fdf -r 5966b71195b4 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h Mon Apr 06 13:46:11 2009 +0100
+++ b/xen/include/xen/sched.h Mon Apr 06 13:49:16 2009 +0100
@@ -552,6 +552,9 @@ uint64_t get_cpu_idle_time(unsigned int
#define is_hvm_vcpu(v) (is_hvm_domain(v->domain))
#define need_iommu(d) ((d)->need_iommu && !(d)->is_hvm)
+void set_vcpu_migration_delay(unsigned int delay);
+unsigned int get_vcpu_migration_delay(void);
+
extern int sched_smt_power_savings;
extern enum cpufreq_controller {
diff -r 1a7457bb1fdf -r 5966b71195b4 xen/include/xsm/xsm.h
--- a/xen/include/xsm/xsm.h Mon Apr 06 13:46:11 2009 +0100
+++ b/xen/include/xsm/xsm.h Mon Apr 06 13:49:16 2009 +0100
@@ -75,6 +75,8 @@ struct xsm_operations {
int (*debug_keys) (void);
int (*getcpuinfo) (void);
int (*availheap) (void);
+ int (*get_pmstat) (void);
+ int (*pm_op) (void);
int (*evtchn_unbound) (struct domain *d, struct evtchn *chn, domid_t id2);
int (*evtchn_interdomain) (struct domain *d1, struct evtchn *chn1,
@@ -282,6 +284,16 @@ static inline int xsm_getcpuinfo (void)
return xsm_call(getcpuinfo());
}
+static inline int xsm_get_pmstat(void)
+{
+ return xsm_call(get_pmstat());
+}
+
+static inline int xsm_pm_op(void)
+{
+ return xsm_call(pm_op());
+}
+
static inline int xsm_evtchn_unbound (struct domain *d1, struct evtchn *chn,
domid_t
id2)
{
diff -r 1a7457bb1fdf -r 5966b71195b4 xen/xsm/dummy.c
--- a/xen/xsm/dummy.c Mon Apr 06 13:46:11 2009 +0100
+++ b/xen/xsm/dummy.c Mon Apr 06 13:49:16 2009 +0100
@@ -130,6 +130,16 @@ static int dummy_debug_keys (void)
}
static int dummy_getcpuinfo (void)
+{
+ return 0;
+}
+
+static int dummy_get_pmstat (void)
+{
+ return 0;
+}
+
+static int dummy_pm_op (void)
{
return 0;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|