Re: [PATCH] sched: Avoid that __wait_on_bit_lock() hangs
From: Oleg Nesterov
Date: Wed Aug 03 2016 - 17:31:29 EST
Hi Bart,
I too can't understand the problem. Perhaps you missed the fact that
abort_exclusive_wait() does everything under wait_queue_head_t->lock ?
On 08/03, Bart Van Assche wrote:
>
> try_to_wake_up() locks task_struct.pi_lock but abort_exclusive_wait() not.
> My assumption is that the following sequence of events leads to the lockup
> that I had mentioned in the description of my patch:
> * try_to_wake_up() is called for the task that will execute
> abort_exclusive_wait().
> * After try_to_wake_up() has checked task_struct.state and before
> autoremove_wake_function() has tried to remove the task from the wait
> queue, abort_exclusive_wait() is executed for the same task.
But we do not care if we race with another try_to_wake_up(), or even with
another exclusive wake_up_nr(wq)/whatever unless wq is the same.
And if this wq is the same, then wake_up_nr() will do try_to_wake_up/autoremove
either before or after abort_exclusive_wait(), wake_up_nr() takes the same
wq->lock.
And this means that abort_exclusive_wait() can't be called "After try_to_wake_up()"
and "before autoremove_wake_function()".
Oleg.