All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Omar Sandoval <osandov@fb.com>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 6/6] block: don't check if adjacent bvecs in one bio can be mergeable
Date: Mon, 11 Mar 2019 15:40:24 +0100	[thread overview]
Message-ID: <20190311144024.GF7850@lst.de> (raw)
In-Reply-To: <20190309013737.27741-7-ming.lei@redhat.com>

> +	bool new_bio;
>  
>  	if (!bio)
>  		return 0;
> @@ -377,9 +377,10 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
>  	fbio = bio;
>  	seg_size = 0;
>  	nr_phys_segs = 0;
> +	new_bio = false;

I'd just initialize it to false in the declaration line.

> +/* only try to merge bvecs into one sg if they are from two bios */
> +static inline bool
> +__blk_segment_map_sg_merge(struct request_queue *q, struct bio_vec *bvec,
> +			   struct bio_vec *bvprv, struct scatterlist **sg)
>  {
>  	int nbytes = bvec->bv_len;
>  
> +	if (!*sg)
> +		return false;
>  
> +	if ((*sg)->length + nbytes > queue_max_segment_size(q))
> +		return false;
> +
> +	if (!biovec_phys_mergeable(q, bvprv, bvec))
> +		return false;
> +
> +	(*sg)->length += nbytes;
> +
> +	return true;
> +}
> +
> +static inline void
> +__blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec,
> +		     struct scatterlist *sglist, struct scatterlist **sg,
> +		     int *nsegs)
> +{
> +	if (bvec->bv_offset + bvec->bv_len <= PAGE_SIZE) {
> +		*sg = blk_next_sg(sg, sglist);
> +		sg_set_page(*sg, bvec->bv_page, bvec->bv_len, bvec->bv_offset);
> +		(*nsegs) += 1;

This branch is basically the same as __blk_bvec_map_sg, I wonder if
we can reuse it.

> +	} else
> +		(*nsegs) += blk_bvec_map_sg(q, bvec, sglist, sg);
>  }

And then maybe just kill off __blk_segment_map_sg entirely by moving
the if else into the caller.

> @@ -535,11 +543,24 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio,
>  	struct bio_vec bvec, bvprv = { NULL };
>  	struct bvec_iter iter;
>  	int nsegs = 0;
> +	bool new_bio = false;
>  
> +	for_each_bio(bio) {
> +		bio_for_each_bvec(bvec, bio, iter) {
> +			/*
> +			 * Only try to merge bvecs from two bios given we
> +			 * have done bio internal merge when adding pages
> +			 * to bio
> +			 */
> +			if (!new_bio || !__blk_segment_map_sg_merge(q,
> +						&bvec, &bvprv, sg))

Somewhat hard to read.  Why not:

			if (new_bio ||
			    !__blk_segment_map_sg_merge(q, &bvec, &bvprv, sg))

That being said I'd really like to see some stats on workloads that
actually trigger cross-bio segment merges.  If we get a lot of those
we are doing something wrong.

  reply	other threads:[~2019-03-11 14:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-09  1:37 [PATCH 0/6] block: enable multi-page bvec for passthrough IO Ming Lei
2019-03-09  1:37 ` Ming Lei
2019-03-09  1:37 ` [PATCH 1/6] block: pass page to xen_biovec_phys_mergeable Ming Lei
2019-03-09  1:37   ` Ming Lei
2019-03-11 14:16   ` Christoph Hellwig
2019-03-11 14:16     ` Christoph Hellwig
2019-03-11 19:57   ` Boris Ostrovsky
2019-03-11 19:57     ` Boris Ostrovsky
2019-03-09  1:37 ` [PATCH 2/6] block: don't merge adjacent bvecs to one segment in bio blk_queue_split Ming Lei
2019-03-09  1:37   ` Ming Lei
2019-03-11 14:21   ` Christoph Hellwig
2019-03-11 14:21     ` Christoph Hellwig
2019-03-12  1:22     ` Ming Lei
2019-03-12  1:22       ` Ming Lei
2019-03-11 19:58   ` Boris Ostrovsky
2019-03-11 19:58     ` Boris Ostrovsky
2019-03-09  1:37 ` [PATCH 3/6] block: check if page is mergeable in one helper Ming Lei
2019-03-11 14:23   ` Christoph Hellwig
2019-03-17  8:05     ` Ming Lei
2019-03-09  1:37 ` [PATCH 4/6] block: put the same page when adding it to bio Ming Lei
2019-03-11 14:28   ` Christoph Hellwig
2019-03-09  1:37 ` [PATCH 5/6] block: enable multi-page bvec for passthrough IO Ming Lei
2019-03-11 14:35   ` Christoph Hellwig
2019-03-12  1:06     ` Ming Lei
2019-03-09  1:37 ` [PATCH 6/6] block: don't check if adjacent bvecs in one bio can be mergeable Ming Lei
2019-03-11 14:40   ` Christoph Hellwig [this message]
2019-03-12  1:19     ` Ming Lei

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=20190311144024.GF7850@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=osandov@fb.com \
    /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.