linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yangerkun <yangerkun@huawei.com>
To: <dhowells@redhat.com>, <viro@zeniv.linux.org.uk>
Cc: <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] pipe: remove needless spin_lock in pipe_read/pipe_write
Date: Mon, 29 Nov 2021 14:22:06 +0800	[thread overview]
Message-ID: <22dd76ec-a50d-a2f1-8001-2a86de1d50c0@huawei.com> (raw)
In-Reply-To: <20211122041135.2450220-1-yangerkun@huawei.com>

ping

On 2021/11/22 12:11, yangerkun wrote:
> Once enable CONFIG_WATCH_QUEUE, we should protect pipe with
> pipe->rd_wait.lock since post_one_notification may write pipe from
> contexts where pipe->mutex cannot be token. But nowdays we will try
> take it for anycase, it seems needless. Besides, pipe_write will break
> once it's pipe with O_NOTIFICATION_PIPE, pipe->rd_wait.lock seems no
> need at all. We make some change base on that, and it can help improve
> performance for some case like pipe_pst1 in libMicro.
> 
> ARMv7 for our scene, before this patch:
>    5483 nsecs/call
> After this patch:
>    4854 nsecs/call
> 
> Signed-off-by: yangerkun <yangerkun@huawei.com>
> ---
>   fs/pipe.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 6d4342bad9f1..e8ced0c50824 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -320,14 +320,18 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
>   
>   			if (!buf->len) {
>   				pipe_buf_release(pipe, buf);
> -				spin_lock_irq(&pipe->rd_wait.lock);
>   #ifdef CONFIG_WATCH_QUEUE
> +				if (pipe->watch_queue)
> +					spin_lock_irq(&pipe->rd_wait.lock);
>   				if (buf->flags & PIPE_BUF_FLAG_LOSS)
>   					pipe->note_loss = true;
>   #endif
>   				tail++;
>   				pipe->tail = tail;
> -				spin_unlock_irq(&pipe->rd_wait.lock);
> +#ifdef CONFIG_WATCH_QUEUE
> +				if (pipe->watch_queue)
> +					spin_unlock_irq(&pipe->rd_wait.lock);
> +#endif
>   			}
>   			total_len -= chars;
>   			if (!total_len)
> @@ -504,16 +508,11 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
>   			 * it, either the reader will consume it or it'll still
>   			 * be there for the next write.
>   			 */
> -			spin_lock_irq(&pipe->rd_wait.lock);
> -
>   			head = pipe->head;
> -			if (pipe_full(head, pipe->tail, pipe->max_usage)) {
> -				spin_unlock_irq(&pipe->rd_wait.lock);
> +			if (pipe_full(head, pipe->tail, pipe->max_usage))
>   				continue;
> -			}
>   
>   			pipe->head = head + 1;
> -			spin_unlock_irq(&pipe->rd_wait.lock);
>   
>   			/* Insert it into the buffer array */
>   			buf = &pipe->bufs[head & mask];
> 

  reply	other threads:[~2021-11-29  6:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22  4:11 [PATCH] pipe: remove needless spin_lock in pipe_read/pipe_write yangerkun
2021-11-29  6:22 ` yangerkun [this message]
2021-12-16  8:31   ` yangerkun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22dd76ec-a50d-a2f1-8001-2a86de1d50c0@huawei.com \
    --to=yangerkun@huawei.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).