From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, linux-nvme@lists.infradead.org
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Wen Xiong <wenxiong@linux.ibm.com>,
Keith Busch <kbusch@kernel.org>, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 1/2] blk-mq: add blk_mq_max_nr_hw_queues()
Date: Sat, 8 Jul 2023 10:02:58 +0800 [thread overview]
Message-ID: <20230708020259.1343736-2-ming.lei@redhat.com> (raw)
In-Reply-To: <20230708020259.1343736-1-ming.lei@redhat.com>
blk_mq_alloc_tag_set() may return less nr_hw_queues in case of kdump
kernel. This way can cause trouble for driver, which needs to calculate
nr_hw_queues first.
If blk_mq_alloc_tag_set() reduces nr_hw_queues for kdump kernel, it
causes trouble for driver, cause real queue topo is actually changed,
then IO may be dispatched to wrong queue.
Prepare for fixing this kind of issue by applying the added helper, so
driver can take blk-mq max nr_hw_queues knowledge into account when
calculating io queues.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-mq.c | 9 +++++++++
include/linux/blk-mq.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5504719b970d..b764da69a416 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -140,6 +140,15 @@ void blk_mq_freeze_queue_wait(struct request_queue *q)
}
EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait);
+/* Max nr_hw_queues for each hw queue type */
+unsigned int blk_mq_max_nr_hw_queues(void)
+{
+ if (is_kdump_kernel())
+ return 1;
+ return nr_cpu_ids;
+}
+EXPORT_SYMBOL_GPL(blk_mq_max_nr_hw_queues);
+
int blk_mq_freeze_queue_wait_timeout(struct request_queue *q,
unsigned long timeout)
{
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 2b7fb8e87793..2407978fbc30 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -713,6 +713,7 @@ int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
const struct blk_mq_ops *ops, unsigned int queue_depth,
unsigned int set_flags);
void blk_mq_free_tag_set(struct blk_mq_tag_set *set);
+unsigned int blk_mq_max_nr_hw_queues(void);
void blk_mq_free_request(struct request *rq);
int blk_rq_poll(struct request *rq, struct io_comp_batch *iob,
--
2.40.1
next prev parent reply other threads:[~2023-07-08 2:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-08 2:02 [PATCH 0/2] blk-mq & nvme-pci: fix io failure in kdump kernel Ming Lei
2023-07-08 2:02 ` Ming Lei [this message]
2023-07-08 2:02 ` [PATCH 2/2] nvme-pci: use blk_mq_max_nr_hw_queues() to calculate io queues Ming Lei
2023-07-10 6:41 ` Christoph Hellwig
2023-07-10 9:14 ` Ming Lei
2023-07-10 16:51 ` Keith Busch
2023-07-11 1:33 ` Ming Lei
2023-07-11 3:35 ` Baoquan He
2023-07-11 3:53 ` Ming Lei
2023-07-11 6:59 ` Baoquan He
2023-07-11 3:55 ` Pingfan Liu
2023-07-11 4:05 ` Pingfan Liu
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=20230708020259.1343736-2-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=wenxiong@linux.ibm.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