[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] scheduler: Implement SCHEDOP sysctl for credit scheduler



# HG changeset patch
# User George Dunlap <george.dunlap@xxxxxxxxxxxxx>
# Date 1329992241 0
# Node ID dd9e8f1ebed1100fad2c01ff977ab66ff96d90b2
# Parent  c4bddb3422ddadbc34f2925ce438ef2dcfc07f52
scheduler: Implement SCHEDOP sysctl for credit scheduler

Allow tslice_ms and ratelimit_us to be modified.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r c4bddb3422dd -r dd9e8f1ebed1 xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Thu Feb 23 10:16:10 2012 +0000
+++ b/xen/common/sched_credit.c Thu Feb 23 10:17:21 2012 +0000
@@ -833,6 +833,36 @@
     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 @@
     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 @@
     .yield          = csched_vcpu_yield,
 
     .adjust         = csched_dom_cntl,
+    .adjust_global  = csched_sys_cntl,
 
     .pick_cpu       = csched_cpu_pick,
     .do_schedule    = csched_schedule,
diff -r c4bddb3422dd -r dd9e8f1ebed1 xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h       Thu Feb 23 10:16:10 2012 +0000
+++ b/xen/include/public/sysctl.h       Thu Feb 23 10:17:21 2012 +0000
@@ -564,6 +564,19 @@
 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_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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.