From: Mike Snitzer <snitzer@redhat.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: axboe@kernel.dk, Ming Lei <tom.leiming@gmail.com>,
hch@lst.de, dm-devel@redhat.com, linux-block@vger.kernel.org
Subject: Re: [for-4.16 PATCH v6 2/3] blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback
Date: Wed, 17 Jan 2018 22:37:23 -0500 [thread overview]
Message-ID: <20180118033723.GA8475@redhat.com> (raw)
In-Reply-To: <20180118032509.GB11167@ming.t460p>
On Wed, Jan 17 2018 at 10:25pm -0500,
Ming Lei <ming.lei@redhat.com> wrote:
> Hi Mike,
>
> On Wed, Jan 17, 2018 at 11:25:57AM -0500, Mike Snitzer wrote:
> > From: Ming Lei <ming.lei@redhat.com>
> >
> > blk_insert_cloned_request() is called in the fast path of a dm-rq driver
> > (e.g. blk-mq request-based DM mpath). blk_insert_cloned_request() uses
> > blk_mq_request_bypass_insert() to directly append the request to the
> > blk-mq hctx->dispatch_list of the underlying queue.
> >
> > 1) This way isn't efficient enough because the hctx spinlock is always
> > used.
> >
> > 2) With blk_insert_cloned_request(), we completely bypass underlying
> > queue's elevator and depend on the upper-level dm-rq driver's elevator
> > to schedule IO. But dm-rq currently can't get the underlying queue's
> > dispatch feedback at all. Without knowing whether a request was issued
> > or not (e.g. due to underlying queue being busy) the dm-rq elevator will
> > not be able to provide effective IO merging (as a side-effect of dm-rq
> > currently blindly destaging a request from its elevator only to requeue
> > it after a delay, which kills any opportunity for merging). This
> > obviously causes very bad sequential IO performance.
> >
> > Fix this by updating blk_insert_cloned_request() to use
> > blk_mq_request_direct_issue(). blk_mq_request_direct_issue() allows a
> > request to be issued directly to the underlying queue and returns the
> > dispatch feedback (blk_status_t). If blk_mq_request_direct_issue()
> > returns BLK_SYS_RESOURCE the dm-rq driver will now use DM_MAPIO_REQUEUE
> > to _not_ destage the request. Whereby preserving the opportunity to
> > merge IO.
> >
> > With this, request-based DM's blk-mq sequential IO performance is vastly
> > improved (as much as 3X in mpath/virtio-scsi testing).
> >
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > [blk-mq.c changes heavily influenced by Ming Lei's initial solution, but
> > they were refactored to make them less fragile and easier to read/review]
> > Signed-off-by: Mike Snitzer <snitzer@redhat.com>
...
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index c117c2baf2c9..f5f0d8456713 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -1731,15 +1731,19 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx,
> >
> > static void __blk_mq_fallback_to_insert(struct blk_mq_hw_ctx *hctx,
> > struct request *rq,
> > - bool run_queue)
> > + bool run_queue, bool bypass_insert)
> > {
> > - blk_mq_sched_insert_request(rq, false, run_queue, false,
> > - hctx->flags & BLK_MQ_F_BLOCKING);
> > + if (!bypass_insert)
> > + blk_mq_sched_insert_request(rq, false, run_queue, false,
> > + hctx->flags & BLK_MQ_F_BLOCKING);
> > + else
> > + blk_mq_request_bypass_insert(rq, run_queue);
> > }
>
> If 'bypass_insert' is true, we don't need to insert the request into
> hctx->dispatch_list for dm-rq, then it causes the issue(use after free)
> reported by Bart and Laurence.
>
> Also this way is the exact opposite of the idea of the improvement,
> we do not want to dispatch request if underlying queue is busy.
Yeap, please see the patch I just posted to fix it.
But your v4 does fallback to using blk_mq_request_bypass_insert() as
well, just in a much narrower case -- specifically:
if (blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q))
Thanks,
Mike
next prev parent reply other threads:[~2018-01-18 3:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 16:25 [for-4.16 PATCH v6 0/3] blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback Mike Snitzer
2018-01-17 16:25 ` [for-4.16 PATCH v6 1/3] blk-mq: factor out a few helpers from __blk_mq_try_issue_directly Mike Snitzer
2018-01-17 16:25 ` [for-4.16 PATCH v6 2/3] blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback Mike Snitzer
2018-01-18 3:25 ` Ming Lei
2018-01-18 3:37 ` Mike Snitzer [this message]
2018-01-18 3:44 ` Ming Lei
2018-01-17 16:25 ` [for-4.16 PATCH v6 3/3] blk-mq-sched: remove unused 'can_block' arg from blk_mq_sched_insert_request Mike Snitzer
2018-01-17 16:50 ` [for-4.16 PATCH v6 0/3] blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback Jens Axboe
2018-01-17 16:58 ` Mike Snitzer
2018-01-17 23:31 ` Bart Van Assche
2018-01-17 23:31 ` Bart Van Assche
2018-01-17 23:43 ` Laurence Oberman
2018-01-17 23:53 ` Bart Van Assche
2018-01-17 23:53 ` Bart Van Assche
2018-01-17 23:57 ` Laurence Oberman
2018-01-18 0:12 ` Laurence Oberman
2018-01-18 0:12 ` Laurence Oberman
2018-01-18 0:54 ` Mike Snitzer
2018-01-18 1:17 ` Laurence Oberman
2018-01-18 3:33 ` [PATCH] blk mq: don't blk_mq_request_bypass_insert _and_ return BLK_STS_RESOURCE Mike Snitzer
2018-01-18 3:39 ` Ming Lei
2018-01-18 3:49 ` Mike Snitzer
2018-01-18 3:52 ` 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=20180118033723.GA8475@redhat.com \
--to=snitzer@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=tom.leiming@gmail.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.