From: Christoph Hellwig <hch@infradead.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@fb.com>,
linux-block@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH 1/2] blk-mq: merge bio into sw queue before plugging
Date: Wed, 24 May 2017 02:48:16 -0700 [thread overview]
Message-ID: <20170524094816.GA30474@infradead.org> (raw)
In-Reply-To: <20170523114736.12026-2-ming.lei@redhat.com>
On Tue, May 23, 2017 at 07:47:35PM +0800, Ming Lei wrote:
> Before blk-mq is introduced, I/O is merged to elevator
> before being putted into plug queue, but blk-mq changed the
> order and makes merging to sw queue basically impossible.
> Then it is observed that throughput of sequential I/O is degraded
> about 10%~20% on virtio-blk in the test[1] if mq-deadline isn't used.
>
> This patch moves the bio merging per sw queue before plugging,
> like what blk_queue_bio() does, and the performance regression is
> fixed under this situation.
>
> [1]. test script:
> sudo fio --direct=1 --size=128G --bsrange=4k-4k --runtime=40 --numjobs=16 --ioengine=libaio --iodepth=64 --group_reporting=1 --filename=/dev/vdb --name=virtio_blk-test-$RW --rw=$RW --output-format=json
>
> RW=read or write
>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> block/blk-mq.c | 53 +++++++++++++++++++++++++++++------------------------
> 1 file changed, 29 insertions(+), 24 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index a69ad122ed66..b7ca64ef15e8 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1446,30 +1446,31 @@ static inline bool hctx_allow_merges(struct blk_mq_hw_ctx *hctx)
> !blk_queue_nomerges(hctx->queue);
> }
> +/* attempt to merge bio into current sw queue */
> +static inline bool blk_mq_merge_bio(struct request_queue *q, struct bio *bio)
> {
> + bool ret = false;
> + struct blk_mq_ctx *ctx = blk_mq_get_ctx(q);
> + struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu);
>
> + if (!hctx_allow_merges(hctx) || !bio_mergeable(bio))
> + goto exit;
>
> + spin_lock(&ctx->lock);
> + ret = blk_mq_attempt_merge(q, ctx, bio);
> + spin_unlock(&ctx->lock);
> +exit:
> + blk_mq_put_ctx(ctx);
> + return ret;
If I'd want to nitpick I'd say that this would probably be a bit
cleaner without the goto..
But otherwise this looks fine to me:
Reviewed-by: Christoph Hellwig <hch@lst.de>
next prev parent reply other threads:[~2017-05-24 9:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 11:47 [PATCH 0/2] blk-mq: merge bio into sw queue before plugging Ming Lei
2017-05-23 11:47 ` [PATCH 1/2] " Ming Lei
2017-05-24 9:48 ` Christoph Hellwig [this message]
2017-05-23 11:47 ` [PATCH 2/2] blk-mq: make per-sw-queue bio merge as default .bio_merge Ming Lei
2017-05-24 9:58 ` Christoph Hellwig
2017-05-24 10:12 ` Ming Lei
2017-05-24 10:31 ` 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=20170524094816.GA30474@infradead.org \
--to=hch@infradead.org \
--cc=axboe@fb.com \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox