Messages in this thread | | | Date | Tue, 25 Aug 2015 12:05:27 +0200 | From | Peter Zijlstra <> | Subject | Re: [PATCH] sched: fix tsk->pi_lock isn't held when do_set_cpus_allowed() |
| |
On Tue, Aug 25, 2015 at 03:59:54PM +0800, Wanpeng Li wrote: > +++ b/kernel/cpuset.c > @@ -2376,8 +2376,12 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask) > > void cpuset_cpus_allowed_fallback(struct task_struct *tsk) > { > + unsigned long flags; > + > rcu_read_lock(); > + raw_spin_lock_irqsave(&tsk->pi_lock, flags); > do_set_cpus_allowed(tsk, task_cs(tsk)->effective_cpus); > + raw_spin_lock_irqsave(&tsk->pi_lock, flags); > rcu_read_unlock();
Aside from the double lock thing that was already pointed out, I think this is wrong, because the select_task_rq() call can already have pi_lock held.
Taking it again would result in a deadlock.
Consider for instance:
try_to_wake_up() raw_spin_lock_irqsave(->pi_lock) select_task_rq() select_ballback_rq() cpuset_cpus_allowed_fallback() raw_spin_lock_irqsave(->pi_lock)
The problem is with the migration path and should be fixed there.
| |