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>,
Jeff Moyer <jmoyer@redhat.com>, Mike Snitzer <snitzer@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: [PATCH 3/4] blk-mq: deal with shared queue mapping reliably
Date: Sun, 16 Dec 2018 10:25:16 +0800 [thread overview]
Message-ID: <20181216022517.26650-4-ming.lei@redhat.com> (raw)
In-Reply-To: <20181216022517.26650-1-ming.lei@redhat.com>
This patch sets map->nr_queues as zero explictly if there is zero
queues for such queue type, then blk_mq_map_swqueue() can become
more robust to deal with shared mappings.
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-mq.c | 3 +++
drivers/nvme/host/pci.c | 37 ++++++++++++++++++++-----------------
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index a4a0895dae65..a737d912c46b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2435,6 +2435,9 @@ static void blk_mq_map_swqueue(struct request_queue *q)
for (j = 0; j < set->nr_maps; j++) {
hctx = blk_mq_map_queue_type(q, j, i);
+ if (!set->map[j].nr_queues)
+ continue;
+
/*
* If the CPU is already set in the mask, then we've
* mapped this one already. This can happen if
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 95bd68be2078..43074c54279e 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -492,29 +492,32 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)
offset = queue_irq_offset(dev);
for (i = 0, qoff = 0; i < set->nr_maps; i++) {
struct blk_mq_queue_map *map = &set->map[i];
+ unsigned nr_queues;
- map->nr_queues = dev->io_queues[i];
- if (!map->nr_queues) {
+ nr_queues = map->nr_queues = dev->io_queues[i];
+ if (!nr_queues) {
BUG_ON(i == HCTX_TYPE_DEFAULT);
- /* shared set, resuse read set parameters */
- map->nr_queues = dev->io_queues[HCTX_TYPE_DEFAULT];
+ /* shared set, resuse default set parameters and table */
+ nr_queues = dev->io_queues[HCTX_TYPE_DEFAULT];
qoff = 0;
offset = queue_irq_offset(dev);
- }
- /*
- * The poll queue(s) doesn't have an IRQ (and hence IRQ
- * affinity), so use the regular blk-mq cpu mapping if
- * poll queue(s) don't share mapping with TYPE_DEFAULT.
- */
- map->queue_offset = qoff;
- if (i != HCTX_TYPE_POLL || !qoff)
- blk_mq_pci_map_queues(map, to_pci_dev(dev->dev), offset);
- else
- blk_mq_map_queues(map);
- qoff += map->nr_queues;
- offset += map->nr_queues;
+ memcpy(map->mq_map, set->map[HCTX_TYPE_DEFAULT].mq_map,
+ nr_cpu_ids * sizeof(map->mq_map[0]));
+ } else {
+ /*
+ * The poll queue(s) doesn't have an IRQ (and hence IRQ
+ * affinity), so use the regular blk-mq cpu mapping.
+ */
+ map->queue_offset = qoff;
+ if (i != HCTX_TYPE_POLL)
+ blk_mq_pci_map_queues(map, to_pci_dev(dev->dev), offset);
+ else
+ blk_mq_map_queues(map);
+ }
+ qoff += nr_queues;
+ offset += nr_queues;
}
return 0;
--
2.9.5
next prev parent reply other threads:[~2018-12-16 2:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-16 2:25 [PATCH 0/4] blk-mq: queue mapping fix & improvement Ming Lei
2018-12-16 2:25 ` [PATCH 1/4] nvme-pci: correct mapping for poll queue(s) Ming Lei
2018-12-16 16:11 ` Christoph Hellwig
2018-12-17 1:00 ` Ming Lei
2018-12-17 7:06 ` Christoph Hellwig
2018-12-17 7:22 ` Ming Lei
2018-12-16 2:25 ` [PATCH 2/4] blk-mq: fix allocation for queue mapping table Ming Lei
2018-12-16 16:15 ` Christoph Hellwig
2018-12-16 2:25 ` Ming Lei [this message]
2018-12-16 16:16 ` [PATCH 3/4] blk-mq: deal with shared queue mapping reliably Christoph Hellwig
2018-12-16 18:39 ` Mike Snitzer
2018-12-16 19:12 ` Jens Axboe
2018-12-17 1:04 ` Ming Lei
2018-12-17 7:44 ` Christoph Hellwig
2018-12-17 8:38 ` Ming Lei
2018-12-17 1:27 ` Ming Lei
2018-12-16 2:25 ` [PATCH 4/4] blk-mq-debugfs: export hctx->type Ming Lei
2018-12-16 16:17 ` Christoph Hellwig
2018-12-16 19:12 ` Jens Axboe
2018-12-17 1:06 ` 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=20181216022517.26650-4-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=jmoyer@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=snitzer@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;
as well as URLs for NNTP newsgroup(s).