Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1212931

Re: [PATCH] sched: fix tsk->pi_lock isn't held when do_set_cpus_allowed()

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] sched: fix tsk->pi_lock isn't held when do_set_cpus_allowed()
Date 2015-08-25 12:20 +0200
Message-ID <q1juF-3vj-9@gated-at.bofh.it> (permalink)
References <q1hCx-P0-5@gated-at.bofh.it> <q1jl0-3k4-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Aug 25, 2015 at 12:05:27PM +0200, Peter Zijlstra wrote:
> 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.

Another problem, migration_call() will have rq->lock held, so you're
proposing to acquire pi_lock while holding rq->lock, this is an
inversion from the regular nesting order.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] sched: fix tsk->pi_lock isn't held when do_set_cpus_allowed() Wanpeng Li <wanpeng.li@hotmail.com> - 2015-08-25 10:20 +0200
  Re: [PATCH] sched: fix tsk->pi_lock isn't held when  do_set_cpus_allowed() Peter Zijlstra <peterz@infradead.org> - 2015-08-25 12:10 +0200
    Re: [PATCH] sched: fix tsk->pi_lock isn't held when  do_set_cpus_allowed() Wanpeng Li <wanpeng.li@hotmail.com> - 2015-08-25 12:20 +0200
    Re: [PATCH] sched: fix tsk->pi_lock isn't held when  do_set_cpus_allowed() Peter Zijlstra <peterz@infradead.org> - 2015-08-25 12:20 +0200
      Re: [PATCH] sched: fix tsk->pi_lock isn't held when  do_set_cpus_allowed() Peter Zijlstra <peterz@infradead.org> - 2015-08-25 12:40 +0200
        Re: [PATCH] sched: fix tsk->pi_lock isn't held when  do_set_cpus_allowed() Peter Zijlstra <peterz@infradead.org> - 2015-08-28 00:20 +0200
          Re: [PATCH] sched: fix tsk->pi_lock isn't held when  do_set_cpus_allowed() Wanpeng Li <wanpeng.li@hotmail.com> - 2015-08-28 03:50 +0200
  Re: [PATCH] sched: fix tsk->pi_lock isn't held when  do_set_cpus_allowed() "T. Zhou" <t.s.zhou@hotmail.com> - 2015-08-27 16:00 +0200

csiph-web