aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/sched_credit2.c
diff options
context:
space:
mode:
authorGeorge Dunlap <george.dunlap@eu.citrix.com>2011-04-27 13:36:15 +0100
committerGeorge Dunlap <george.dunlap@eu.citrix.com>2011-04-27 13:36:15 +0100
commitff38d3faa7d0e1734237e81c2fea95e18c510dcd (patch)
tree7589a305a45183a0eb2b2ba61dbd91276a6dd17f /xen/common/sched_credit2.c
parent9841d94c95bf97c3cd3c9ca14170fc88dc3b8305 (diff)
downloadxen-ff38d3faa7d0e1734237e81c2fea95e18c510dcd.tar.gz
xen-ff38d3faa7d0e1734237e81c2fea95e18c510dcd.tar.bz2
xen-ff38d3faa7d0e1734237e81c2fea95e18c510dcd.zip
credit2: add a callback to migrate to a new cpu
In credit2, there needs to be a strong correlation between v->processor and the runqueue to which a vcpu is assigned; much of the code relies on this invariant. Allow credit2 to manage the actual migration itself. This fixes the most recent credit2 bug reported on the list (Xen BUG at sched_credit2.c:1606) in Xen 4.1, as well as the bug at sched_credit2.c:811 in -unstable (which catches the same condition earlier). Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Diffstat (limited to 'xen/common/sched_credit2.c')
-rw-r--r--xen/common/sched_credit2.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index 792d662575..517ec8c49c 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -1352,32 +1352,29 @@ out:
static int
csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc)
{
- struct csched_vcpu * const svc = CSCHED_VCPU(vc);
int new_cpu;
- /* The scheduler interface doesn't have an explicit mechanism to
- * involve the choosable scheduler in the migrate process, so we
- * infer that a change may happen by the call to cpu_pick, and
- * remove it from the old runqueue while the lock for the old
- * runqueue is held. It can't be actively waiting to run. It
- * will be added to the new runqueue when it next wakes.
- *
- * If we want to be able to call pick() separately, we need to add
- * a mechansim to remove a vcpu from an old processor / runqueue
- * before releasing the lock. */
- BUG_ON(__vcpu_on_runq(svc));
-
new_cpu = choose_cpu(ops, vc);
- /* If we're suggesting moving to a different runqueue, remove it
- * from the old runqueue while we have the lock. It will be added
- * to the new one when it wakes. */
- if ( svc->rqd != NULL
- && RQD(ops, new_cpu) != svc->rqd )
- runq_deassign(ops, vc);
return new_cpu;
}
+static void
+csched_vcpu_migrate(
+ const struct scheduler *ops, struct vcpu *vc, unsigned int new_cpu)
+{
+ struct csched_vcpu * const svc = CSCHED_VCPU(vc);
+ struct csched_runqueue_data *trqd;
+
+ /* Check if new_cpu is valid */
+ BUG_ON(!cpu_isset(new_cpu, CSCHED_PRIV(ops)->initialized));
+
+ trqd = RQD(ops, new_cpu);
+
+ if ( trqd != svc->rqd )
+ migrate(ops, svc, trqd, NOW());
+}
+
static int
csched_dom_cntl(
const struct scheduler *ops,
@@ -2121,6 +2118,7 @@ const struct scheduler sched_credit2_def = {
.adjust = csched_dom_cntl,
.pick_cpu = csched_cpu_pick,
+ .migrate = csched_vcpu_migrate,
.do_schedule = csched_schedule,
.context_saved = csched_context_saved,