From: axboe@kernel.dk (Jens Axboe)
Subject: [PATCH 09/14] blk-mq: ensure that plug lists don't straddle hardware queues
Date: Thu, 25 Oct 2018 15:16:21 -0600 [thread overview]
Message-ID: <20181025211626.12692-10-axboe@kernel.dk> (raw)
In-Reply-To: <20181025211626.12692-1-axboe@kernel.dk>
Since we insert per hardware queue, we have to ensure that every
request on the plug list being inserted belongs to the same
hardware queue.
Signed-off-by: Jens Axboe <axboe at kernel.dk>
---
block/blk-mq.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 60a951c4934c..52b07188b39a 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1621,6 +1621,27 @@ static int plug_ctx_cmp(void *priv, struct list_head *a, struct list_head *b)
blk_rq_pos(rqa) < blk_rq_pos(rqb)));
}
+/*
+ * Need to ensure that the hardware queue matches, so we don't submit
+ * a list of requests that end up on different hardware queues.
+ */
+static bool ctx_match(struct request *req, struct blk_mq_ctx *ctx,
+ unsigned int flags)
+{
+ if (req->mq_ctx != ctx)
+ return false;
+
+ /*
+ * If we just have one map, then we know the hctx will match
+ * if the ctx matches
+ */
+ if (req->q->tag_set->nr_maps == 1)
+ return true;
+
+ return blk_mq_map_queue(req->q, req->cmd_flags, ctx->cpu) ==
+ blk_mq_map_queue(req->q, flags, ctx->cpu);
+}
+
void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
{
struct blk_mq_ctx *this_ctx;
@@ -1628,7 +1649,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
struct request *rq;
LIST_HEAD(list);
LIST_HEAD(ctx_list);
- unsigned int depth;
+ unsigned int depth, this_flags;
list_splice_init(&plug->mq_list, &list);
@@ -1636,13 +1657,14 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
this_q = NULL;
this_ctx = NULL;
+ this_flags = 0;
depth = 0;
while (!list_empty(&list)) {
rq = list_entry_rq(list.next);
list_del_init(&rq->queuelist);
BUG_ON(!rq->q);
- if (rq->mq_ctx != this_ctx) {
+ if (!ctx_match(rq, this_ctx, this_flags)) {
if (this_ctx) {
trace_block_unplug(this_q, depth, !from_schedule);
blk_mq_sched_insert_requests(this_q, this_ctx,
@@ -1650,6 +1672,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
from_schedule);
}
+ this_flags = rq->cmd_flags;
this_ctx = rq->mq_ctx;
this_q = rq->q;
depth = 0;
--
2.17.1
next prev parent reply other threads:[~2018-10-25 21:16 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 21:16 [PATCHSET 0/14] Add support for multiple queue maps Jens Axboe
2018-10-25 21:16 ` [PATCH 01/14] blk-mq: kill q->mq_map Jens Axboe
2018-10-27 14:19 ` jianchao.wang
2018-10-27 16:48 ` Jens Axboe
2018-10-27 16:52 ` Jens Axboe
2018-10-29 2:02 ` jianchao.wang
2018-10-29 2:40 ` jianchao.wang
2018-10-29 3:00 ` Jens Axboe
2018-10-29 9:03 ` jianchao.wang
2018-10-28 16:10 ` Christoph Hellwig
2018-10-29 7:27 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 02/14] blk-mq: abstract out queue map Jens Axboe
2018-10-29 7:30 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 03/14] blk-mq: provide dummy blk_mq_map_queue_type() helper Jens Axboe
2018-10-29 7:30 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 04/14] blk-mq: pass in request/bio flags to queue mapping Jens Axboe
2018-10-29 7:35 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 05/14] blk-mq: allow software queue to map to multiple hardware queues Jens Axboe
2018-10-29 7:37 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 06/14] blk-mq: add 'type' attribute to the sysfs hctx directory Jens Axboe
2018-10-29 7:38 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 07/14] blk-mq: support multiple hctx maps Jens Axboe
2018-10-29 7:39 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 08/14] blk-mq: separate number of hardware queues from nr_cpu_ids Jens Axboe
2018-10-29 7:40 ` Hannes Reinecke
2018-10-25 21:16 ` Jens Axboe [this message]
2018-10-29 7:40 ` [PATCH 09/14] blk-mq: ensure that plug lists don't straddle hardware queues Hannes Reinecke
2018-10-25 21:16 ` [PATCH 10/14] blk-mq: initial support for multiple queue maps Jens Axboe
2018-10-29 7:41 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 11/14] irq: add support for allocating (and affinitizing) sets of IRQs Jens Axboe
2018-10-25 21:52 ` Keith Busch
2018-10-25 23:07 ` Jens Axboe
2018-10-29 7:43 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 12/14] nvme: utilize two queue maps, one for reads and one for writes Jens Axboe
2018-10-29 7:46 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 13/14] block: add REQ_HIPRI and inherit it from IOCB_HIPRI Jens Axboe
2018-10-29 7:47 ` Hannes Reinecke
2018-10-25 21:16 ` [PATCH 14/14] nvme: add separate poll queue map Jens Axboe
2018-10-29 7:48 ` Hannes Reinecke
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=20181025211626.12692-10-axboe@kernel.dk \
--to=axboe@kernel.dk \
/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