]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvme-pci: use block layer helpers to calculate num of queues
authorDaniel Wagner <wagi@kernel.org>
Tue, 17 Jun 2025 13:43:25 +0000 (15:43 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 1 Jul 2025 16:24:19 +0000 (10:24 -0600)
The calculation of the upper limit for queues does not depend solely on
the number of possible CPUs; for example, the isolcpus kernel
command-line option must also be considered.

To account for this, the block layer provides a helper function to
retrieve the maximum number of queues. Use it to set an appropriate
upper queue number limit.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20250617-isolcpus-queue-counters-v1-3-13923686b54b@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/pci.c

index 38be1505dbd96337ced16a7aebc3213d6ea97a9b..a509dc1f1d1400bc0de6d2f9424c126d9b966751 100644 (file)
@@ -108,7 +108,7 @@ static int io_queue_count_set(const char *val, const struct kernel_param *kp)
        int ret;
 
        ret = kstrtouint(val, 10, &n);
-       if (ret != 0 || n > num_possible_cpus())
+       if (ret != 0 || n > blk_mq_num_possible_queues(0))
                return -EINVAL;
        return param_set_uint(val, kp);
 }
@@ -2629,7 +2629,8 @@ static unsigned int nvme_max_io_queues(struct nvme_dev *dev)
         */
        if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS)
                return 1;
-       return num_possible_cpus() + dev->nr_write_queues + dev->nr_poll_queues;
+       return blk_mq_num_possible_queues(0) + dev->nr_write_queues +
+               dev->nr_poll_queues;
 }
 
 static int nvme_setup_io_queues(struct nvme_dev *dev)