linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] scsi: storvsc: Parameterize number hardware queues
@ 2021-02-24 23:29 Melanie Plageman (Microsoft)
  2021-03-02 17:28 ` Michael Kelley
  2021-03-04  4:09 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Melanie Plageman (Microsoft) @ 2021-02-24 23:29 UTC (permalink / raw)
  To: linux-scsi
  Cc: andres, haiyangz, jejb, kys, linux-hyperv, linux-kernel,
	martin.petersen, mikelley, sthemmin, wei.liu,
	Melanie Plageman (Microsoft)

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.

Signed-off-by: Melanie Plageman (Microsoft) <melanieplageman@gmail.com>
---
Updated since v3:
- permissions in octal
- param type changed to unsigned int
- removed value checking from module init function
- simplified value checking logic in probe function

 drivers/scsi/storvsc_drv.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 6bc5453cea8a..dfe005c03734 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -366,10 +366,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");
 
@@ -1907,6 +1911,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);
@@ -2015,8 +2020,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.
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH v4] scsi: storvsc: Parameterize number hardware queues
  2021-02-24 23:29 [PATCH v4] scsi: storvsc: Parameterize number hardware queues Melanie Plageman (Microsoft)
@ 2021-03-02 17:28 ` Michael Kelley
  2021-03-04  4:09 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Kelley @ 2021-03-02 17:28 UTC (permalink / raw)
  To: melanieplageman, linux-scsi
  Cc: andres, Haiyang Zhang, jejb, KY Srinivasan, linux-hyperv,
	linux-kernel, martin.petersen, Stephen Hemminger, wei.liu,
	melanieplageman

From: Melanie Plageman (Microsoft) <melanieplageman@gmail.com> Sent: Wednesday, February 24, 2021 3:30 PM
> 
> 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.
> 
> Signed-off-by: Melanie Plageman (Microsoft) <melanieplageman@gmail.com>
> ---
> Updated since v3:
> - permissions in octal
> - param type changed to unsigned int
> - removed value checking from module init function
> - simplified value checking logic in probe function
> 
>  drivers/scsi/storvsc_drv.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 6bc5453cea8a..dfe005c03734 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -366,10 +366,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");
> 
> @@ -1907,6 +1911,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);
> @@ -2015,8 +2020,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.
> --
> 2.20.1

Reviewed-by: Michael Kelley <mikelley@microsoft.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] scsi: storvsc: Parameterize number hardware queues
  2021-02-24 23:29 [PATCH v4] scsi: storvsc: Parameterize number hardware queues Melanie Plageman (Microsoft)
  2021-03-02 17:28 ` Michael Kelley
@ 2021-03-04  4:09 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2021-03-04  4:09 UTC (permalink / raw)
  To: Melanie Plageman (Microsoft)
  Cc: linux-scsi, andres, haiyangz, jejb, kys, linux-hyperv,
	linux-kernel, martin.petersen, mikelley, sthemmin, wei.liu


Melanie,

> 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.

Applied to 5.13/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-04  4:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 23:29 [PATCH v4] scsi: storvsc: Parameterize number hardware queues Melanie Plageman (Microsoft)
2021-03-02 17:28 ` Michael Kelley
2021-03-04  4:09 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).