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

From: Bart Van Assche
Date: Wed Aug 03 2016 - 15:31:57 EST


On 08/03/2016 11:11 AM, Peter Zijlstra wrote:
That seems to do the right thing, so clearly I misunderstand. Please
clarify.

Hello Peter,

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.

Please note that the call stack I had mentioned in my e-mail had been reported before. See e.g.
* Michael Shaver, Kernel deadlock during mdadm reshape, July 2016 (http://www.spinics.net/lists/raid/msg53056.html).
* Bart Van Assche, Kernel hangs in truncate_inode_pages(), August 2012 (https://lkml.org/lkml/2012/8/24/185).

Bart.