]> git.baikalelectronics.ru Git - kernel.git/commit
pipe: don't use 'pipe_wait() for basic pipe IO
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 7 Dec 2019 21:53:09 +0000 (13:53 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 7 Dec 2019 21:53:09 +0000 (13:53 -0800)
commit579976091c2d6defbc8cc962b38026c4c4dd02d1
tree71f2a601e325fd5724e05b685675e7c7b749ebcf
parentccbb23e3fa272a66c0c9292a9011febc8cf1f587
pipe: don't use 'pipe_wait() for basic pipe IO

pipe_wait() may be simple, but since it relies on the pipe lock, it
means that we have to do the wakeup while holding the lock.  That's
unfortunate, because the very first thing the waked entity will want to
do is to get the pipe lock for itself.

So get rid of the pipe_wait() usage by simply releasing the pipe lock,
doing the wakeup (if required) and then using wait_event_interruptible()
to wait on the right condition instead.

wait_event_interruptible() handles races on its own by comparing the
wakeup condition before and after adding itself to the wait queue, so
you can use an optimistic unlocked condition for it.

Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/pipe.c