Linux block layer
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 3/4] block: optimize blk_bio_segment_split for single-page bvec
Date: Wed, 27 Feb 2019 20:40:12 +0800	[thread overview]
Message-ID: <20190227124013.4828-4-ming.lei@redhat.com> (raw)
In-Reply-To: <20190227124013.4828-1-ming.lei@redhat.com>

Introduce a fast path for single-page bvec IO, then we can avoid
to call bvec_split_segs() unnecessarily.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-merge.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index c1ad8abbd9d6..9402a7c3ba22 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -286,10 +286,16 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
 		bvprv = bv;
 		bvprvp = &bvprv;
 
-		if (bvec_split_segs(q, &bv, &nsegs, &seg_size,
-				    &front_seg_size, &sectors))
+		if (bv.bv_offset + bv.bv_len <= PAGE_SIZE) {
+			nsegs++;
+			seg_size = bv.bv_len;
+			sectors += bv.bv_len >> 9;
+			if (nsegs == 1 && seg_size > front_seg_size)
+				front_seg_size = seg_size;
+		} else if (bvec_split_segs(q, &bv, &nsegs, &seg_size,
+				    &front_seg_size, &sectors)) {
 			goto split;
-
+		}
 	}
 
 	do_split = false;
-- 
2.9.5


  parent reply	other threads:[~2019-02-27 12:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27 12:40 [PATCH 0/4] block: optimize for single-page bvec workloads Ming Lei
2019-02-27 12:40 ` [PATCH 1/4] block: introduce bvec_nth_page() Ming Lei
2019-02-27 12:40 ` [PATCH 2/4] block: optimize __blk_segment_map_sg() for single-page bvec Ming Lei
2019-02-27 12:40 ` Ming Lei [this message]
2019-02-27 12:40 ` [PATCH 4/4] block: introduce mp_bvec_for_each_page() for iterating over page Ming Lei
2019-02-28 14:13   ` Christoph Hellwig
2019-02-28 15:10     ` Jens Axboe
2019-02-27 13:25 ` [PATCH 0/4] block: optimize for single-page bvec workloads Jens Axboe
2019-02-27 15:41   ` Ming Lei
2019-02-27 15:54     ` 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=20190227124013.4828-4-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    /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