diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index d547716e09..220ff0dd6b 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -998,6 +998,9 @@ csched_vcpu_insert(const struct scheduler *ops, struct vcpu *vc) BUG_ON( is_idle_vcpu(vc) ); + /* This is safe because vc isn't yet being scheduled */ + vc->processor = csched_cpu_pick(ops, vc); + lock = vcpu_schedule_lock_irq(vc); if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) && !vc->is_running ) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 3d2716a60d..7ec7f625e1 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2055,9 +2055,16 @@ csched2_vcpu_insert(const struct scheduler *ops, struct vcpu *vc) ASSERT(!is_idle_vcpu(vc)); ASSERT(list_empty(&svc->runq_elem)); - /* Add vcpu to runqueue of initial processor */ + /* csched2_cpu_pick() expects the pcpu lock to be held */ lock = vcpu_schedule_lock_irq(vc); + vc->processor = csched2_cpu_pick(ops, vc); + + spin_unlock_irq(lock); + + lock = vcpu_schedule_lock_irq(vc); + + /* Add vcpu to runqueue of initial processor */ runq_assign(ops, vc); vcpu_schedule_unlock_irq(lock, vc); diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index bd3a2a00b3..41c61a7d29 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -874,6 +874,9 @@ rt_vcpu_insert(const struct scheduler *ops, struct vcpu *vc) BUG_ON( is_idle_vcpu(vc) ); + /* This is safe because vc isn't yet being scheduled */ + vc->processor = rt_cpu_pick(ops, vc); + lock = vcpu_schedule_lock_irq(vc); now = NOW();