Skip to content

Commit

Permalink
pipe: Conditionalise wakeup in pipe_read()
Browse files Browse the repository at this point in the history
Only do a wakeup in pipe_read() if we made space in a completely full
buffer.  The producer shouldn't be waiting on pipe->wait otherwise.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
David Howells committed Nov 15, 2019
1 parent b667b86 commit 8446487
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,13 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
spin_lock_irq(&pipe->wait.lock);
tail++;
pipe->tail = tail;
do_wakeup = 0;
wake_up_interruptible_sync_poll_locked(
&pipe->wait, EPOLLOUT | EPOLLWRNORM);
do_wakeup = 1;
if (head - (tail - 1) == pipe->max_usage)
wake_up_interruptible_sync_poll_locked(
&pipe->wait, EPOLLOUT | EPOLLWRNORM);
spin_unlock_irq(&pipe->wait.lock);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
if (head - (tail - 1) == pipe->max_usage)
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
total_len -= chars;
if (!total_len)
Expand Down Expand Up @@ -361,11 +363,6 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
ret = -ERESTARTSYS;
break;
}
if (do_wakeup) {
wake_up_interruptible_sync_poll(&pipe->wait, EPOLLOUT | EPOLLWRNORM);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
do_wakeup = 0;
}
pipe_wait(pipe);
}
__pipe_unlock(pipe);
Expand Down

0 comments on commit 8446487

Please sign in to comment.