[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4 of 9] xen: Implement SCHEDOP sysctl for credit scheduler
Allow tslice_ms and ratelimit_us to be modified. Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx> diff -r a4e58388859e -r 0b230c5ac8b7 xen/common/sched_credit.c --- a/xen/common/sched_credit.c Wed Feb 22 16:08:28 2012 +0000 +++ b/xen/common/sched_credit.c Wed Feb 22 16:08:28 2012 +0000 @@ -833,6 +833,36 @@ csched_dom_cntl( return 0; } +static int +csched_sys_cntl(const struct scheduler *ops, + struct xen_sysctl_scheduler_op *sc) +{ + int rc = -EINVAL; + xen_sysctl_credit_schedule_t *params = &sc->u.sched_credit; + struct csched_private *prv = CSCHED_PRIV(ops); + + switch ( sc->cmd ) + { + case XEN_SYSCTL_SCHEDOP_putinfo: + if (params->tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX + || params->tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN + || params->ratelimit_us > XEN_SYSCTL_SCHED_RATELIMIT_MAX + || params->ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN + || MICROSECS(params->ratelimit_us) > MILLISECS(params->tslice_ms) ) + goto out; + prv->tslice_ms = params->tslice_ms; + prv->ratelimit_us = params->ratelimit_us; + /* FALLTHRU */ + case XEN_SYSCTL_SCHEDOP_getinfo: + params->tslice_ms = prv->tslice_ms; + params->ratelimit_us = prv->ratelimit_us; + rc = 0; + break; + } + out: + return rc; +} + static void * csched_alloc_domdata(const struct scheduler *ops, struct domain *dom) { @@ -1566,6 +1596,28 @@ csched_init(struct scheduler *ops) INIT_LIST_HEAD(&prv->active_sdom); prv->master = UINT_MAX; + if ( sched_credit_tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX + || sched_credit_tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN ) + { + printk("WARNING: sched_credit_tslice_ms outside of valid range [%d,%d].\n" + " Resetting to default %u\n", + XEN_SYSCTL_CSCHED_TSLICE_MIN, + XEN_SYSCTL_CSCHED_TSLICE_MAX, + CSCHED_DEFAULT_TSLICE_MS); + sched_credit_tslice_ms = CSCHED_DEFAULT_TSLICE_MS; + } + + if ( sched_ratelimit_us > XEN_SYSCTL_SCHED_RATELIMIT_MAX + || sched_ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN ) + { + printk("WARNING: sched_ratelimit_us outside of valid range [%d,%d].\n" + " Resetting to default %u\n", + XEN_SYSCTL_SCHED_RATELIMIT_MIN, + XEN_SYSCTL_SCHED_RATELIMIT_MAX, + SCHED_DEFAULT_RATELIMIT_US); + sched_ratelimit_us = SCHED_DEFAULT_RATELIMIT_US; + } + prv->tslice_ms = sched_credit_tslice_ms; prv->ticks_per_tslice = CSCHED_TICKS_PER_TSLICE; if ( prv->tslice_ms < prv->ticks_per_tslice ) @@ -1641,6 +1693,7 @@ const struct scheduler sched_credit_def .yield = csched_vcpu_yield, .adjust = csched_dom_cntl, + .adjust_global = csched_sys_cntl, .pick_cpu = csched_cpu_pick, .do_schedule = csched_schedule, diff -r a4e58388859e -r 0b230c5ac8b7 xen/include/public/sysctl.h --- a/xen/include/public/sysctl.h Wed Feb 22 16:08:28 2012 +0000 +++ b/xen/include/public/sysctl.h Wed Feb 22 16:08:28 2012 +0000 @@ -564,6 +564,19 @@ struct xen_sysctl_arinc653_schedule { typedef struct xen_sysctl_arinc653_schedule xen_sysctl_arinc653_schedule_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_arinc653_schedule_t); +struct xen_sysctl_credit_schedule { + /* Length of timeslice in milliseconds */ +#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000 +#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1 + unsigned tslice_ms; + /* Rate limit (minimum timeslice) in microseconds */ +#define XEN_SYSCTL_SCHED_RATELIMIT_MAX 500000 +#define XEN_SYSCTL_SCHED_RATELIMIT_MIN 100 + unsigned ratelimit_us; +}; +typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t); + /* XEN_SYSCTL_scheduler_op */ /* Set or get info? */ #define XEN_SYSCTL_SCHEDOP_putinfo 0 @@ -576,6 +589,7 @@ struct xen_sysctl_scheduler_op { struct xen_sysctl_sched_arinc653 { XEN_GUEST_HANDLE_64(xen_sysctl_arinc653_schedule_t) schedule; } sched_arinc653; + struct xen_sysctl_credit_schedule sched_credit; } u; }; typedef struct xen_sysctl_scheduler_op xen_sysctl_scheduler_op_t; _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |