All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
	linux-nvme@lists.infradead.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org
Cc: linux-block@vger.kernel.org, Wen Xiong <wenxiong@linux.ibm.com>,
	Keith Busch <kbusch@kernel.org>, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH V3 14/14] blk-mq: add helpers for treating kdump kernel
Date: Tue,  8 Aug 2023 18:42:39 +0800	[thread overview]
Message-ID: <20230808104239.146085-15-ming.lei@redhat.com> (raw)
In-Reply-To: <20230808104239.146085-1-ming.lei@redhat.com>

Clean up code a bit by adding helpers for treating kdump kernel
specially.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-mq.c | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 617d6f849a7b..afa51df2f0d3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -147,6 +147,8 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait);
  * driver has to take blk-mq max supported nr_hw_queues into account
  * when figuring out nr_hw_queues from hardware info, for avoiding
  * inconsistency between driver and blk-mq.
+ *
+ * Limit to single queue in case of kdump kernel
  */
 unsigned int blk_mq_max_nr_hw_queues(void)
 {
@@ -4370,7 +4372,7 @@ static void blk_mq_update_queue_map(struct blk_mq_tag_set *set)
 	if (set->nr_maps == 1)
 		set->map[HCTX_TYPE_DEFAULT].nr_queues = set->nr_hw_queues;
 
-	if (set->ops->map_queues && !is_kdump_kernel()) {
+	if (set->ops->map_queues) {
 		int i;
 
 		/*
@@ -4420,6 +4422,22 @@ static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
 	return 0;
 }
 
+/* Limit to single map in case of kdump kernel */
+static unsigned int blk_mq_max_nr_maps(void)
+{
+	if (is_kdump_kernel())
+		return 1;
+	return HCTX_MAX_TYPES;
+}
+
+/* Limit to 64 in case of kdump kernel */
+static unsigned int blk_mq_max_depth(void)
+{
+	if (is_kdump_kernel())
+		return 64;
+	return BLK_MQ_MAX_DEPTH;
+}
+
 /*
  * Alloc a tag set to be associated with one or more request queues.
  * May fail with EINVAL for various error conditions. May adjust the
@@ -4456,16 +4474,13 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
 	else if (set->nr_maps > HCTX_MAX_TYPES)
 		return -EINVAL;
 
-	/*
-	 * If a crashdump is active, then we are potentially in a very
-	 * memory constrained environment. Limit us to 1 queue and
-	 * 64 tags to prevent using too much memory.
-	 */
-	if (is_kdump_kernel()) {
-		set->nr_hw_queues = 1;
-		set->nr_maps = 1;
-		set->queue_depth = min(64U, set->queue_depth);
-	}
+	if (set->nr_hw_queues > blk_mq_max_nr_hw_queues())
+		set->nr_hw_queues = blk_mq_max_nr_hw_queues();
+	if (set->nr_maps > blk_mq_max_nr_maps())
+		set->nr_maps = blk_mq_max_nr_maps();
+	if (set->queue_depth > blk_mq_max_depth())
+		set->queue_depth = blk_mq_max_depth();
+
 	/*
 	 * There is no use for more h/w queues than cpus if we just have
 	 * a single map
@@ -4495,7 +4510,7 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
 						  GFP_KERNEL, set->numa_node);
 		if (!set->map[i].mq_map)
 			goto out_free_mq_map;
-		set->map[i].nr_queues = is_kdump_kernel() ? 1 : set->nr_hw_queues;
+		set->map[i].nr_queues = set->nr_hw_queues;
 	}
 
 	blk_mq_update_queue_map(set);
-- 
2.40.1


  parent reply	other threads:[~2023-08-08 16:09 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08 10:42 [PATCH V3 0/14] blk-mq: fix wrong queue mapping for kdump kernel Ming Lei
2023-08-08 10:42 ` [PATCH V3 01/14] blk-mq: add blk_mq_max_nr_hw_queues() Ming Lei
2023-08-09 13:44   ` Christoph Hellwig
2023-08-10  0:09     ` Ming Lei
2023-08-10  0:09       ` Ming Lei
2023-08-10  0:09       ` Ming Lei
2023-08-10  1:18       ` Baoquan He
2023-08-10  1:18         ` Baoquan He
2023-08-10  1:18         ` Baoquan He
2023-08-10  2:06         ` Ming Lei
2023-08-10  2:06           ` Ming Lei
2023-08-10  2:06           ` Ming Lei
2023-08-10  3:01           ` Baoquan He
2023-08-10  3:01             ` Baoquan He
2023-08-10  3:01             ` Baoquan He
2023-08-11  7:53             ` Hari Bathini
2023-08-11  7:53               ` Hari Bathini
2023-08-11  7:53               ` Hari Bathini
2023-09-05  5:03               ` Baoquan He
2023-09-05  5:03                 ` Baoquan He
2023-09-05  5:03                 ` Baoquan He
2023-08-11 13:10       ` Christoph Hellwig
2023-08-11 13:10         ` Christoph Hellwig
2023-08-11 13:10         ` Christoph Hellwig
2023-08-08 10:42 ` [PATCH V3 02/14] nvme-pci: use blk_mq_max_nr_hw_queues() to calculate io queues Ming Lei
2023-08-08 10:42 ` [PATCH V3 03/14] ublk: limit max allowed nr_hw_queues Ming Lei
2023-08-08 10:42 ` [PATCH V3 04/14] virtio-blk: limit max allowed submit queues Ming Lei
2023-08-08 10:42   ` Ming Lei
2023-08-10 19:23   ` Michael S. Tsirkin
2023-08-10 19:23     ` Michael S. Tsirkin
2023-08-08 10:42 ` [PATCH V3 05/14] scsi: core: add helper of scsi_max_nr_hw_queues() Ming Lei
2023-08-08 10:42 ` [PATCH V3 06/14] scsi: lpfc: use blk_mq_max_nr_hw_queues() to calculate io vectors Ming Lei
2023-08-08 10:42 ` [PATCH V3 07/14] scsi: mpi3mr: take blk_mq_max_nr_hw_queues() into account for calculating " Ming Lei
2023-08-08 10:42 ` [PATCH V3 08/14] scsi: megaraid: " Ming Lei
2023-08-08 10:42 ` [PATCH V3 09/14] scsi: mpt3sas: " Ming Lei
2023-08-08 10:42 ` [PATCH V3 10/14] scsi: pm8001: " Ming Lei
2023-08-08 10:42 ` [PATCH V3 11/14] scsi: hisi: " Ming Lei
2023-08-08 10:42 ` [PATCH V3 12/14] scsi: ufs: limit max allowed nr_hw_queues Ming Lei
2023-08-08 10:42 ` [PATCH V3 13/14] scsi: storvsc: " Ming Lei
2023-08-08 10:42 ` Ming Lei [this message]
2023-08-10  8:00   ` [PATCH V3 14/14] blk-mq: add helpers for treating kdump kernel kernel test robot

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=20230808104239.146085-15-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=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --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 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.