aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDario Faggioli <dario.faggioli@citrix.com>2013-04-17 10:57:30 +0000
committerIan Campbell <ian.campbell@citrix.com>2013-04-17 12:11:14 +0100
commitebb064aa22715ae473f72468d093e7a05e3c3c58 (patch)
tree7d4cd7cf72400e3f3e3e53711ad120158f2a2cd6
parent225fa55e53efa8b8e3d964d8572c89001d547d4e (diff)
downloadxen-ebb064aa22715ae473f72468d093e7a05e3c3c58.tar.gz
xen-ebb064aa22715ae473f72468d093e7a05e3c3c58.tar.bz2
xen-ebb064aa22715ae473f72468d093e7a05e3c3c58.zip
xen: sched_credit: when picking, make sure we get an idle one, if any
The pcpu picking algorithm treats two threads of a SMT core the same. More specifically, if one is idle and the other one is busy, they both will be assigned a weight of 1. Therefore, when picking begins, if the first target pcpu is the busy thread (and if there are no other idle pcpu than its sibling), that will never change. This change fixes this by ensuring that, before entering the core of the picking algorithm, the target pcpu is an idle one (if there is an idle pcpu at all, of course). Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Juergen Gross <juergen.gross@ts.fujitsu.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Keir Fraser <keir@xen.org>
-rw-r--r--xen/common/sched_credit.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index 9e9ef33a49..64e76c5bef 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -532,6 +532,21 @@ _csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, bool_t commit)
if ( vc->processor == cpu && IS_RUNQ_IDLE(cpu) )
cpumask_set_cpu(cpu, &idlers);
cpumask_and(&cpus, &cpus, &idlers);
+
+ /*
+ * It is important that cpu points to an idle processor, if a suitable
+ * one exists (and we can use cpus to check and, possibly, choose a new
+ * CPU, as we just &&-ed it with idlers). In fact, if we are on SMT, and
+ * cpu points to a busy thread with an idle sibling, both the threads
+ * will be considered the same, from the "idleness" calculation point
+ * of view", preventing vcpu from being moved to the thread that is
+ * actually idle.
+ *
+ * Notice that cpumask_test_cpu() is quicker than cpumask_empty(), so
+ * we check for it first.
+ */
+ if ( !cpumask_test_cpu(cpu, &cpus) && !cpumask_empty(&cpus) )
+ cpu = cpumask_cycle(cpu, &cpus);
cpumask_clear_cpu(cpu, &cpus);
while ( !cpumask_empty(&cpus) )