From: Wanpeng Li <wanpengli@xxxxxxxxxxx> Consider the task afffinity constrain when yield to a task. Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx> Cc: Radim Krčmář <rkrcmar@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Signed-off-by: Wanpeng Li <wanpengli@xxxxxxxxxxx> --- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 092f7c4..11001ff 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5102,6 +5102,9 @@ int __sched yield_to(struct task_struct *p, bool preempt) if (task_running(p_rq, p) || p->state) goto out_unlock; + if (!cpumask_test_cpu(smp_processor_id(), &p->cpus_allowed)) + goto out_unlock; + yielded = curr->sched_class->yield_to_task(rq, p, preempt); if (yielded) { schedstat_inc(rq->yld_count); -- 2.7.4