[PATCH] configurable NVME IO queue count

Sridhar Balaraman sbalaraman at parallelwireless.com
Wed Dec 20 09:53:16 PST 2023


Some NVME products are providing more number of IO queues,
so driver is allocating queue based on number of CPU or
maximum number of queues by device, whichever is least.
At the same time, corresponding queues would be mapped to IRQs.
But in case of RT Linux, where we need isolated CPU and free from IRQ.
Unfortunately NVME IRQ couldn't be reduced due to more number of CPUs.
After making IO queues as configurable parameters,
we can reduce number of IO queues which inturn reduces number of IRQs.

Before configuring queue count:
[    4.384566] nvme nvme0: pci function 0000:05:00.0
[    4.450307] nvme nvme0: 32/0/0 default/read/poll queues
[    4.457427]  nvme0n1: p1 p2

After configuring queue count to 2:
[    5.920776] nvme nvme0: pci function 0000:05:00.0
[    5.939455] nvme nvme0: 2/0/0 default/read/poll queues
[    5.941487]  nvme0n1: p1 p2

Signed-off-by: Sridhar Balaraman <sbalaraman at parallelwireless.com>
---
 drivers/nvme/host/pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 3622c5c9515f..051d99e0264d 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -86,6 +86,10 @@ static const struct kernel_param_ops io_queue_count_ops = {
        .get = param_get_uint,
 };

+static unsigned int total_io_queues;
+module_param_cb(total_io_queues, &io_queue_count_ops, &total_io_queues, 0644);
+MODULE_PARM_DESC(total_io_queues, "Restrict total number of queues to use for IO.");
+
 static unsigned int write_queues;
 module_param_cb(write_queues, &io_queue_count_ops, &write_queues, 0644);
 MODULE_PARM_DESC(write_queues,
@@ -2171,7 +2175,10 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
         * If tags are shared with admin queue (Apple bug), then
         * make sure we only use one IO queue.
         */
-       if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS)
+
+       if (total_io_queues)
+               nr_io_queues = total_io_queues;
+       else if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS)
                nr_io_queues = 1;
        else
                nr_io_queues = min(nvme_max_io_queues(dev),
--
2.25.1




More information about the Linux-nvme mailing list