public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ming Lei <[email protected]>
To: Pavel Begunkov <[email protected]>
Cc: [email protected], Jens Axboe <[email protected]>,
	Christoph Hellwig <[email protected]>,
	Matthew Wilcox <[email protected]>,
	Johannes Weiner <[email protected]>,
	Alexander Viro <[email protected]>,
	"Darrick J . Wong" <[email protected]>,
	"Martin K . Petersen" <[email protected]>,
	Jonathan Corbet <[email protected]>,
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected], Christoph Hellwig <[email protected]>
Subject: Re: [PATCH v3 5/7] iov_iter: optimise bvec iov_iter_advance()
Date: Mon, 11 Jan 2021 10:55:48 +0800	[thread overview]
Message-ID: <20210111025548.GF4147870@T590> (raw)
In-Reply-To: <58552e3ba333650ccd425823cb9dc0b949350959.1610170479.git.asml.silence@gmail.com>

On Sat, Jan 09, 2021 at 04:03:01PM +0000, Pavel Begunkov wrote:
> iov_iter_advance() is heavily used, but implemented through generic
> means. For bvecs there is a specifically crafted function for that, so
> use bvec_iter_advance() instead, it's faster and slimmer.
> 
> Reviewed-by: Christoph Hellwig <[email protected]>
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
>  lib/iov_iter.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 7de304269641..9b1c109dc8a9 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1065,6 +1065,21 @@ static void pipe_advance(struct iov_iter *i, size_t size)
>  	pipe_truncate(i);
>  }
>  
> +static void iov_iter_bvec_advance(struct iov_iter *i, size_t size)
> +{
> +	struct bvec_iter bi;
> +
> +	bi.bi_size = i->count;
> +	bi.bi_bvec_done = i->iov_offset;
> +	bi.bi_idx = 0;
> +	bvec_iter_advance(i->bvec, &bi, size);
> +
> +	i->bvec += bi.bi_idx;
> +	i->nr_segs -= bi.bi_idx;
> +	i->count = bi.bi_size;
> +	i->iov_offset = bi.bi_bvec_done;
> +}
> +
>  void iov_iter_advance(struct iov_iter *i, size_t size)
>  {
>  	if (unlikely(iov_iter_is_pipe(i))) {
> @@ -1075,6 +1090,10 @@ void iov_iter_advance(struct iov_iter *i, size_t size)
>  		i->count -= size;
>  		return;
>  	}
> +	if (iov_iter_is_bvec(i)) {
> +		iov_iter_bvec_advance(i, size);
> +		return;
> +	}
>  	iterate_and_advance(i, size, v, 0, 0, 0)
>  }
>  EXPORT_SYMBOL(iov_iter_advance);
> -- 
> 2.24.0
> 

Reviewed-by: Ming Lei <[email protected]>

-- 
Ming


  reply	other threads:[~2021-01-11  2:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09 16:02 [PATCH v3 0/7] no-copy bvec Pavel Begunkov
2021-01-09 16:02 ` [PATCH v3 1/7] splice: don't generate zero-len segement bvecs Pavel Begunkov
2021-01-11  2:48   ` Ming Lei
2021-01-09 16:02 ` [PATCH v3 2/7] bvec/iter: disallow zero-length segment bvecs Pavel Begunkov
2021-01-11  2:49   ` Ming Lei
2021-01-09 16:02 ` [PATCH v3 3/7] block/psi: remove PSI annotations from direct IO Pavel Begunkov
2021-01-11  2:52   ` Ming Lei
2021-01-09 16:03 ` [PATCH v3 4/7] target/file: allocate the bvec array as part of struct target_core_file_cmd Pavel Begunkov
2021-01-11  2:53   ` Ming Lei
2021-01-09 16:03 ` [PATCH v3 5/7] iov_iter: optimise bvec iov_iter_advance() Pavel Begunkov
2021-01-11  2:55   ` Ming Lei [this message]
2021-01-09 16:03 ` [PATCH v3 6/7] bio: add a helper calculating nr segments to alloc Pavel Begunkov
2021-01-11  2:57   ` Ming Lei
2021-01-09 16:03 ` [PATCH v3 7/7] bio: don't copy bvec for direct IO Pavel Begunkov
2021-01-11  3:00   ` Ming Lei
2021-01-25 15:58 ` [PATCH v3 0/7] no-copy bvec Jens Axboe

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=20210111025548.GF4147870@T590 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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