]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
credit: update timeslice under lock
authorJuergen Gross <jgross@suse.com>
Tue, 2 Feb 2016 13:03:06 +0000 (14:03 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 2 Feb 2016 13:03:06 +0000 (14:03 +0100)
When updating the timeslice of the credit scheduler protect the
scheduler's private data by it's lock. Today a possible race could
result only in some weird scheduling decisions during one timeslice,
but further adjustments will need the lock anyway.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
xen/common/sched_credit.c

index 03fb2c2d674044d12f3a71aa49a9892567ddd64f..8fbbd54637c1a9540510ab0e0d9a8213114a677c 100644 (file)
@@ -1101,6 +1101,7 @@ csched_sys_cntl(const struct scheduler *ops,
     int rc = -EINVAL;
     xen_sysctl_credit_schedule_t *params = &sc->u.sched_credit;
     struct csched_private *prv = CSCHED_PRIV(ops);
+    unsigned long flags;
 
     switch ( sc->cmd )
     {
@@ -1112,8 +1113,12 @@ csched_sys_cntl(const struct scheduler *ops,
                     || params->ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN))
             || MICROSECS(params->ratelimit_us) > MILLISECS(params->tslice_ms) )
                 goto out;
+
+        spin_lock_irqsave(&prv->lock, flags);
         __csched_set_tslice(prv, params->tslice_ms);
         prv->ratelimit_us = params->ratelimit_us;
+        spin_unlock_irqrestore(&prv->lock, flags);
+
         /* FALLTHRU */
     case XEN_SYSCTL_SCHEDOP_getinfo:
         params->tslice_ms = prv->tslice_ms;