Skip to content

Commit db44fc0

Browse files
yongzhang0Ingo Molnar
authored andcommitted
sched: Avoid going ahead if ->cpus_allowed is not changed
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>
1 parent 61eadef commit db44fc0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎kernel/sched.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5946,13 +5946,15 @@ int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)
59465946

59475947
rq = task_rq_lock(p, &flags);
59485948

5949+
if (cpumask_equal(&p->cpus_allowed, new_mask))
5950+
goto out;
5951+
59495952
if (!cpumask_intersects(new_mask, cpu_active_mask)) {
59505953
ret = -EINVAL;
59515954
goto out;
59525955
}
59535956

5954-
if (unlikely((p->flags & PF_THREAD_BOUND) && p != current &&
5955-
!cpumask_equal(&p->cpus_allowed, new_mask))) {
5957+
if (unlikely((p->flags & PF_THREAD_BOUND) && p != current)) {
59565958
ret = -EINVAL;
59575959
goto out;
59585960
}

0 commit comments

Comments
 (0)