Re: [PATCH] sched: Avoid that __wait_on_bit_lock() hangs

From: Bart Van Assche
Date: Wed Aug 03 2016 - 20:05:54 EST


On 08/03/2016 02:30 PM, Oleg Nesterov wrote:
I too can't understand the problem. Perhaps you missed the fact that
abort_exclusive_wait() does everything under wait_queue_head_t->lock ?

[ ... ]

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()".

Hello Oleg,

I had noticed that abort_exclusive_wait() locks and unlocks wait_queue_head_t->lock.

What I had overlooked is that if try_to_wake_up() is called (indirectly) by __wake_up_common() that then wait_queue_head_t->lock is held. However, not all try_to_wake_up() callers hold that lock. Since I'm not a scheduler expert I would appreciate it if someone who is more familiar with the scheduler could explain me how the two patches that I posted in the context of this e-mail thread can cause a behavior difference.

Thanks,

Bart.