[PATCH] nvme-pci: introduce parameter to clamp io queues

Keith Busch <[email protected]> Thu, 30 Jul 2026 09:20:55 -0700
Newsgroups org.infradead.lists.linux-nvme
Message-ID <[email protected]>
From: Keith Busch <[email protected]>

Large deployments can have the nvme driver's resource requests easily
exceed the platform's interrupt capabilities leading to an unbalanced
allocation. The driver doesn't know what devices it may see, so it can
not determine reasonable limits for itself. Provide a user settable
module parameter to limit the number of IO queues the driver may
request.

Link: https://lore.kernel.org/lkml/CAKudn=3DrGv-xwAwTis8wpg31mxekyE4YH-E8=
[email protected]/
Reported-by: santhosh kumar <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
---
 drivers/nvme/host/pci.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 375e7a1fc91dc..cb80f0c73562f 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -109,6 +109,11 @@ static unsigned int io_queue_depth =3D 1024;
 module_param_cb(io_queue_depth, &io_queue_depth_ops, &io_queue_depth, 06=
44);
 MODULE_PARM_DESC(io_queue_depth, "set io queue depth, should >=3D 2 and =
< 4096");
=20
+static unsigned short max_io_queues;
+module_param(max_io_queues, ushort, 0644);
+MODULE_PARM_DESC(max_io_queues,
+		 "max io queues to ask for (default 0 means no limit)");
+
 static struct quirk_entry *nvme_pci_quirk_list;
 static unsigned int nvme_pci_quirk_count;
=20
@@ -2953,8 +2958,8 @@ static unsigned int nvme_max_io_queues(struct nvme_=
dev *dev)
 	 */
 	if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS)
 		return 1;
-	return blk_mq_num_possible_queues(0) + dev->nr_write_queues +
-		dev->nr_poll_queues;
+	return min_not_zero(max_io_queues, blk_mq_num_possible_queues(0) +
+				dev->nr_write_queues + dev->nr_poll_queues);
 }
=20
 static int nvme_setup_io_queues(struct nvme_dev *dev)
--=20
2.53.0-Meta