[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fe167a90-1503-7ca2-4150-eeffd5cb1378@yandex-team.ru>
Date: Sun, 27 Oct 2019 18:57:35 +0300
From: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
To: David Howells <dhowells@...hat.com>, torvalds@...ux-foundation.org
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Peter Zijlstra <peterz@...radead.org>,
nicolas.dichtel@...nd.com, raven@...maw.net,
Christian Brauner <christian@...uner.io>,
keyrings@...r.kernel.org, linux-usb@...r.kernel.org,
linux-block@...r.kernel.org, linux-security-module@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-api@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 07/10] pipe: Conditionalise wakeup in pipe_read() [ver
#2]
On 23/10/2019 23.18, David Howells wrote:
> 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.
We could go further and wakeup writer only when at least half of buffer is empty.
This gives better batching and reduces rate of context switches.
https://lore.kernel.org/lkml/157219118016.7078.16223055699799396042.stgit@buzz/T/#u
>
> Signed-off-by: David Howells <dhowells@...hat.com>
> ---
>
> fs/pipe.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 1274305772fb..e3a8f10750c9 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -327,11 +327,13 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
> spin_lock_irq(&pipe->wait.lock);
> tail++;
> pipe_commit_read(pipe, 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)
> @@ -360,11 +362,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);
>
>
Powered by blists - more mailing lists