Skip to contentSkip to conversation

xen: correct changing credit scheduler's timeslice

PATCH In review Juergen Gross 2 participants 4 messages Feb 2, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover xen: correct changing credit scheduler's timeslice

When the timeslice of Xen's credit scheduler is changed via tools the domain weights are no longer honored correctly.

Changes in V2:
- moved locking to csched_sys_cntl() as suggested by Jan
- split up into two patches as requested by Dario

Juergen Gross (2):
xen: update timeslice under lock
xen: recalculate per-cpupool credits when updating timeslice

 xen/common/sched_credit.c | 6 ++++++
 1 file changed, 6 insertions(+)
Signature · 1 line
2.6.2
#1 lore raw

PATCH v2 1/2 xen: update timeslice under lock

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.

---
 xen/common/sched_credit.c | 5 +++++
 1 file changed, 5 insertions(+)
xen/common/sched_credit.c +5 -0
index 03fb2c2..8fbbd54 100644
@@ -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;
Signature · 1 line
2.6.2
#2 lore raw

PATCH v2 2/2 xen: recalculate per-cpupool credits when updating timeslice

In reply to Juergen Gross

When modifying the timeslice of the credit scheduler in a cpupool the cpupool global credit value (n_cpus * credits_per_tslice) isn't recalculated. This will lead to wrong scheduling decisions later.

Do the recalculation when updating the timeslice.

---
 xen/common/sched_credit.c | 1 +
 1 file changed, 1 insertion(+)
xen/common/sched_credit.c +1 -0
index 8fbbd54..671bbee 100644
@@ -1092,6 +1092,7 @@ __csched_set_tslice(struct csched_private *prv, unsigned timeslice)
         prv->ticks_per_tslice = 1;
     prv->tick_period_us = prv->tslice_ms * 1000 / prv->ticks_per_tslice;
     prv->credits_per_tslice = CSCHED_CREDITS_PER_MSEC * prv->tslice_ms;
+    prv->credit = prv->credits_per_tslice * prv->ncpus;
 }
 
 static int
Signature · 1 line
2.6.2
Reviewed-by on the v2 series
#3 lore raw
In reply to Juergen Gross
Quoted 7 lines · Juergen Gross

When the timeslice of Xen's credit scheduler is changed via tools the domain weights are no longer honored correctly.

Changes in V2:
- moved locking to csched_sys_cntl() as suggested by Jan
- split up into two patches as requested by Dario

Aha, perfect example of race condition over email! :-P

No big deal, though, I'm fine with this (split) variant.

Quoted 4 lines

Juergen Gross (2):
  xen: update timeslice under lock
  xen: recalculate per-cpupool credits when updating timeslice

Both patches:

Thanks,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel