All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Pavel Begunkov' <asml.silence@gmail.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2 1/2] iov_iter: optimise iov_iter_npages for bvec
Date: Fri, 20 Nov 2020 13:29:14 +0000	[thread overview]
Message-ID: <e8067cc132b449b9b0e910622b5210ad@AcuMS.aculab.com> (raw)
In-Reply-To: <ab04202d0f8c1424da47251085657c436d762785.1605827965.git.asml.silence@gmail.com>

From: Pavel Begunkov
> Sent: 19 November 2020 23:25
>
> The block layer spends quite a while in iov_iter_npages(), but for the
> bvec case the number of pages is already known and stored in
> iter->nr_segs, so it can be returned immediately as an optimisation
> 
> Perf for an io_uring benchmark with registered buffers (i.e. bvec) shows
> ~1.5-2.0% total cycle count spent in iov_iter_npages(), that's dropped
> by this patch to ~0.2%.
> 
> Reviewed-by: Jens Axboe <axboe@kernel.dk>
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>  lib/iov_iter.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 1635111c5bd2..0fa7ac330acf 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1594,6 +1594,8 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages)
>  		return 0;
>  	if (unlikely(iov_iter_is_discard(i)))
>  		return 0;
> +	if (unlikely(iov_iter_is_bvec(i)))
> +		return min_t(int, i->nr_segs, maxpages);
> 
>  	if (unlikely(iov_iter_is_pipe(i))) {

Is it worth putting an extra condition around these three 'unlikely' cases.
ie:
	if (unlikely((iov_iter_type(i) & (ITER_DISCARD | ITER_BVEC | ITER_PIPE)) {
		if (iov_iter_is_discard(i))
			return 0;
		if (iov_iter_is_bvec(i))
			return min_t(int, i->nr_segs, maxpages);
		/* Must be ITER_PIPE */

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  parent reply	other threads:[~2020-11-20 13:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 23:24 [PATCH v2 0/2] optimise iov_iter Pavel Begunkov
2020-11-19 23:24 ` [PATCH v2 1/2] iov_iter: optimise iov_iter_npages for bvec Pavel Begunkov
2020-11-20  1:20   ` Matthew Wilcox
2020-11-20  1:39     ` Pavel Begunkov
2020-11-20  1:49       ` Matthew Wilcox
2020-11-20  1:56         ` Pavel Begunkov
2020-11-20  2:06           ` Matthew Wilcox
2020-11-20  2:08             ` Pavel Begunkov
2020-11-20  2:24             ` Ming Lei
2020-11-20 17:22               ` Pavel Begunkov
2020-11-20 17:23                 ` Pavel Begunkov
2020-11-20  2:22       ` Ming Lei
2020-11-20  2:25         ` Pavel Begunkov
2020-11-20  2:54           ` Matthew Wilcox
2020-11-20  8:14             ` Christoph Hellwig
2020-11-20 12:39               ` Matthew Wilcox
2020-11-20 13:00                 ` Pavel Begunkov
2020-11-20 13:13                   ` Matthew Wilcox
2020-11-20  9:57             ` Pavel Begunkov
2020-11-20 13:29   ` David Laight [this message]
2020-11-19 23:24 ` [PATCH v2 2/2] iov_iter: optimise iter type checking Pavel Begunkov

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=e8067cc132b449b9b0e910622b5210ad@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.