]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
scsi: storvsc: Parameterize number hardware queues
authorMelanie Plageman (Microsoft) <melanieplageman@gmail.com>
Wed, 2 Jun 2021 21:21:44 +0000 (15:21 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 18 Jun 2021 09:06:55 +0000 (11:06 +0200)
BugLink: https://bugs.launchpad.net/bugs/1930626
Add ability to set the number of hardware queues with new module parameter,
storvsc_max_hw_queues. The default value remains the number of CPUs.  This
functionality is useful in some environments (e.g. Microsoft Azure) where
decreasing the number of hardware queues has been shown to improve
performance.

Link: https://lore.kernel.org/r/20210224232948.4651-1-melanieplageman@gmail.com
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Melanie Plageman (Microsoft) <melanieplageman@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a81a38cc6ddaf128c7ca9e3fffff21c243f33c97)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Colin King <colin.king@canonical.com>
Acked-by: Guilherme Piccoli <gpiccoli@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/scsi/storvsc_drv.c

index e416a60641581b6564b0b354405c3c4332bffe74..b97561eae67182f97b8afdf20d71dcac94709189 100644 (file)
@@ -378,10 +378,14 @@ static u32 max_outstanding_req_per_channel;
 static int storvsc_change_queue_depth(struct scsi_device *sdev, int queue_depth);
 
 static int storvsc_vcpus_per_sub_channel = 4;
+static unsigned int storvsc_max_hw_queues;
 
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 
+module_param(storvsc_max_hw_queues, uint, 0644);
+MODULE_PARM_DESC(storvsc_max_hw_queues, "Maximum number of hardware queues");
+
 module_param(storvsc_vcpus_per_sub_channel, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_vcpus_per_sub_channel, "Ratio of VCPUs to subchannels");
 
@@ -1897,6 +1901,7 @@ static int storvsc_probe(struct hv_device *device,
 {
        int ret;
        int num_cpus = num_online_cpus();
+       int num_present_cpus = num_present_cpus();
        struct Scsi_Host *host;
        struct hv_host_device *host_dev;
        bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false);
@@ -2010,8 +2015,17 @@ static int storvsc_probe(struct hv_device *device,
         * For non-IDE disks, the host supports multiple channels.
         * Set the number of HW queues we are supporting.
         */
-       if (!dev_is_ide)
-               host->nr_hw_queues = num_present_cpus();
+       if (!dev_is_ide) {
+               if (storvsc_max_hw_queues > num_present_cpus) {
+                       storvsc_max_hw_queues = 0;
+                       storvsc_log(device, STORVSC_LOGGING_WARN,
+                               "Resetting invalid storvsc_max_hw_queues value to default.\n");
+               }
+               if (storvsc_max_hw_queues)
+                       host->nr_hw_queues = storvsc_max_hw_queues;
+               else
+                       host->nr_hw_queues = num_present_cpus;
+       }
 
        /*
         * Set the error handler work queue.