On Tue, Feb 18, 2020 at 9:36 AM Linus Torvalds torvalds@linux-foundation.org wrote:
The things that change the number of readers or writers should simply use "wake_up_all()".
So I think the right fix is the attached patch. Since you had such a lovely test-case, let me go test it too ;)
Good that I did. I missed the _real_ case of this - pipe_release(). Because that used a different wakeup function.
In fact, that case uses wake_up_interruptible_sync_poll(), which doesn't have the "all" version.
But it doesn't actually need that fancy thing, since it's only meant for "let's avoid waking up things that don't need these poll keys", and the whole point is that now we're closing the pipe so we should wake up everybody.
And in fact the test for "are there readers or writers" was nonsensical. We shouldn't wake up readers just because they still exist. We should wake up readers only if they exist, _and_ there are no writers left (and vice versa).
Anyway, new patch attached. This hasn't been tested either, but I'll let you know if it's broken too ;)
Linus