Skip to content

Commit

Permalink
sched: Avoid going ahead if ->cpus_allowed is not changed
Browse files Browse the repository at this point in the history
If cpumask_equal(&p->cpus_allowed, new_mask) is true, seems
there is no reason to prevent set_cpus_allowed_ptr() return
directly.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Acked-by: Hillf Danton <dhillf@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110509140705.GA2219@zhy
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Yong Zhang authored and Ingo Molnar committed May 16, 2011
1 parent 61eadef commit db44fc0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -5946,13 +5946,15 @@ int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)

rq = task_rq_lock(p, &flags);

if (cpumask_equal(&p->cpus_allowed, new_mask))
goto out;

if (!cpumask_intersects(new_mask, cpu_active_mask)) {
ret = -EINVAL;
goto out;
}

if (unlikely((p->flags & PF_THREAD_BOUND) && p != current &&
!cpumask_equal(&p->cpus_allowed, new_mask))) {
if (unlikely((p->flags & PF_THREAD_BOUND) && p != current)) {
ret = -EINVAL;
goto out;
}
Expand Down

0 comments on commit db44fc0

Please sign in to comment.