diff -r 9f6dec0d25cd xen/common/sched_arinc653.c --- a/xen/common/sched_arinc653.c Mon Mar 14 17:20:11 2011 +0000 +++ b/xen/common/sched_arinc653.c Tue Mar 15 09:39:10 2011 +0100 @@ -612,7 +612,7 @@ a653sched_do_schedule( * @return Number of selected physical CPU */ static int -a653sched_pick_cpu(const struct scheduler *ops, struct vcpu *vc) +a653sched_pick_cpu(const struct scheduler *ops, struct vcpu *vc, int proposal) { /* this implementation only supports one physical CPU */ return 0; diff -r 9f6dec0d25cd xen/common/sched_credit.c --- a/xen/common/sched_credit.c Mon Mar 14 17:20:11 2011 +0000 +++ b/xen/common/sched_credit.c Tue Mar 15 09:39:10 2011 +0100 @@ -459,7 +459,7 @@ __csched_vcpu_is_migrateable(struct vcpu } static int -_csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, bool_t commit) +_csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, int proposal, bool_t commit) { cpumask_t cpus; cpumask_t idlers; @@ -473,6 +473,10 @@ _csched_cpu_pick(const struct scheduler */ online = CSCHED_CPUONLINE(vc->domain->cpupool); cpus_and(cpus, *online, vc->cpu_affinity); + + if ( (proposal >= 0) && cpu_isset(proposal, *online) ) + return proposal; + cpu = cpu_isset(vc->processor, cpus) ? vc->processor : cycle_cpu(vc->processor, cpus); @@ -548,9 +552,9 @@ _csched_cpu_pick(const struct scheduler } static int -csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc) +csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, int proposal) { - return _csched_cpu_pick(ops, vc, 1); + return _csched_cpu_pick(ops, vc, proposal, 1); } static inline void @@ -635,7 +639,7 @@ csched_vcpu_acct(struct csched_private * { __csched_vcpu_acct_start(prv, svc); } - else if ( _csched_cpu_pick(ops, current, 0) != cpu ) + else if ( _csched_cpu_pick(ops, current, -1, 0) != cpu ) { CSCHED_VCPU_STAT_CRANK(svc, migrate_r); CSCHED_STAT_CRANK(migrate_running); diff -r 9f6dec0d25cd xen/common/sched_credit2.c --- a/xen/common/sched_credit2.c Mon Mar 14 17:20:11 2011 +0000 +++ b/xen/common/sched_credit2.c Tue Mar 15 09:39:10 2011 +0100 @@ -1350,7 +1350,7 @@ out: } static int -csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc) +csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, int proposal) { struct csched_vcpu * const svc = CSCHED_VCPU(vc); int new_cpu; diff -r 9f6dec0d25cd xen/common/sched_sedf.c --- a/xen/common/sched_sedf.c Mon Mar 14 17:20:11 2011 +0000 +++ b/xen/common/sched_sedf.c Tue Mar 15 09:39:10 2011 +0100 @@ -442,13 +442,15 @@ static void sedf_destroy_domain(const st sedf_free_domdata(ops, d->sched_priv); } -static int sedf_pick_cpu(const struct scheduler *ops, struct vcpu *v) +static int sedf_pick_cpu(const struct scheduler *ops, struct vcpu *v, int proposal) { cpumask_t online_affinity; cpumask_t *online; online = SEDF_CPUONLINE(v->domain->cpupool); cpus_and(online_affinity, v->cpu_affinity, *online); + if ( (proposal >= 0) && cpu_isset(proposal, online_affinity) ) + return proposal; return first_cpu(online_affinity); } diff -r 9f6dec0d25cd xen/common/schedule.c --- a/xen/common/schedule.c Mon Mar 14 17:20:11 2011 +0000 +++ b/xen/common/schedule.c Tue Mar 15 09:39:10 2011 +0100 @@ -393,9 +393,10 @@ static void vcpu_migrate(struct vcpu *v) static void vcpu_migrate(struct vcpu *v) { unsigned long flags; - unsigned int old_cpu, new_cpu; + unsigned int old_cpu, new_cpu, proposal; spinlock_t *old_lock, *new_lock; + proposal = -1; old_cpu = new_cpu = v->processor; for ( ; ; ) { @@ -430,10 +431,11 @@ static void vcpu_migrate(struct vcpu *v) old_cpu = v->processor; if ( old_lock == per_cpu(schedule_data, old_cpu).schedule_lock ) { - new_cpu = SCHED_OP(VCPU2OP(v), pick_cpu, v); + new_cpu = SCHED_OP(VCPU2OP(v), pick_cpu, v, proposal); if ( (new_lock == per_cpu(schedule_data, new_cpu).schedule_lock) && cpu_isset(new_cpu, v->domain->cpupool->cpu_valid) ) break; + proposal = new_cpu; } if ( old_lock != new_lock ) diff -r 9f6dec0d25cd xen/include/xen/sched-if.h --- a/xen/include/xen/sched-if.h Mon Mar 14 17:20:11 2011 +0000 +++ b/xen/include/xen/sched-if.h Tue Mar 15 09:39:10 2011 +0100 @@ -167,7 +167,7 @@ struct scheduler { struct task_slice (*do_schedule) (const struct scheduler *, s_time_t, bool_t tasklet_work_scheduled); - int (*pick_cpu) (const struct scheduler *, struct vcpu *); + int (*pick_cpu) (const struct scheduler *, struct vcpu *, int); int (*adjust) (const struct scheduler *, struct domain *, struct xen_domctl_scheduler_op *); int (*adjust_global) (const struct scheduler *,