linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] storvsc: setup 1:1 mapping between hardware queue and CPU queue
@ 2019-08-19 19:35 longli
  2019-08-22 10:55 ` Ming Lei
  0 siblings, 1 reply; 3+ messages in thread
From: longli @ 2019-08-19 19:35 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Sasha Levin,
	James E.J. Bottomley, Martin K. Petersen, linux-hyperv,
	linux-scsi, linux-kernel
  Cc: Long Li

From: Long Li <longli@microsoft.com>

storvsc doesn't use a dedicated hardware queue for a given CPU queue. When
issuing I/O, it selects returning CPU (hardware queue) dynamically based on
vmbus channel usage across all channels.

This patch sets up a 1:1 mapping between hardware queue and CPU queue, thus
avoiding unnecessary locking at upper layer when issuing I/O.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/scsi/storvsc_drv.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index b89269120a2d..26c16d40ec46 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1682,6 +1682,18 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
 	return 0;
 }
 
+static int storvsc_map_queues(struct Scsi_Host *shost)
+{
+	unsigned int cpu;
+	struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
+
+	for_each_possible_cpu(cpu) {
+		qmap->mq_map[cpu] = cpu;
+	}
+
+	return 0;
+}
+
 static struct scsi_host_template scsi_driver = {
 	.module	=		THIS_MODULE,
 	.name =			"storvsc_host_t",
@@ -1697,6 +1709,7 @@ static struct scsi_host_template scsi_driver = {
 	.this_id =		-1,
 	/* Make sure we dont get a sg segment crosses a page boundary */
 	.dma_boundary =		PAGE_SIZE-1,
+	.map_queues =		storvsc_map_queues,
 	.no_write_same =	1,
 	.track_queue_depth =	1,
 };
@@ -1836,8 +1849,7 @@ static int storvsc_probe(struct hv_device *device,
 	/*
 	 * Set the number of HW queues we are supporting.
 	 */
-	if (stor_device->num_sc != 0)
-		host->nr_hw_queues = stor_device->num_sc + 1;
+	host->nr_hw_queues = num_possible_cpus();
 
 	/*
 	 * Set the error handler work queue.
-- 
2.17.1


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

* Re: [PATCH] storvsc: setup 1:1 mapping between hardware queue and CPU queue
  2019-08-19 19:35 [PATCH] storvsc: setup 1:1 mapping between hardware queue and CPU queue longli
@ 2019-08-22 10:55 ` Ming Lei
  2019-08-22 19:31   ` Long Li
  0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2019-08-22 10:55 UTC (permalink / raw)
  To: longli
  Cc: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Sasha Levin,
	James E.J. Bottomley, Martin K. Petersen, linux-hyperv,
	Linux SCSI List, Linux Kernel Mailing List, Long Li

On Tue, Aug 20, 2019 at 3:36 AM <longli@linuxonhyperv.com> wrote:
>
> From: Long Li <longli@microsoft.com>
>
> storvsc doesn't use a dedicated hardware queue for a given CPU queue. When
> issuing I/O, it selects returning CPU (hardware queue) dynamically based on
> vmbus channel usage across all channels.
>
> This patch sets up a 1:1 mapping between hardware queue and CPU queue, thus
> avoiding unnecessary locking at upper layer when issuing I/O.
>
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
>  drivers/scsi/storvsc_drv.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index b89269120a2d..26c16d40ec46 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -1682,6 +1682,18 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
>         return 0;
>  }
>
> +static int storvsc_map_queues(struct Scsi_Host *shost)
> +{
> +       unsigned int cpu;
> +       struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
> +
> +       for_each_possible_cpu(cpu) {
> +               qmap->mq_map[cpu] = cpu;
> +       }

Block layer provides the helper of blk_mq_map_queues(), so suggest you to use
the default cpu mapping, instead of inventing a new one.

thanks,
Ming Lei

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

* RE: [PATCH] storvsc: setup 1:1 mapping between hardware queue and CPU queue
  2019-08-22 10:55 ` Ming Lei
@ 2019-08-22 19:31   ` Long Li
  0 siblings, 0 replies; 3+ messages in thread
From: Long Li @ 2019-08-22 19:31 UTC (permalink / raw)
  To: Ming Lei, longli
  Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, Sasha Levin,
	James E.J. Bottomley, Martin K. Petersen, linux-hyperv,
	Linux SCSI List, Linux Kernel Mailing List

>>>Subject: Re: [PATCH] storvsc: setup 1:1 mapping between hardware queue
>>>and CPU queue
>>>
>>>On Tue, Aug 20, 2019 at 3:36 AM <longli@linuxonhyperv.com> wrote:
>>>>
>>>> From: Long Li <longli@microsoft.com>
>>>>
>>>> storvsc doesn't use a dedicated hardware queue for a given CPU queue.
>>>> When issuing I/O, it selects returning CPU (hardware queue)
>>>> dynamically based on vmbus channel usage across all channels.
>>>>
>>>> This patch sets up a 1:1 mapping between hardware queue and CPU
>>>queue,
>>>> thus avoiding unnecessary locking at upper layer when issuing I/O.
>>>>
>>>> Signed-off-by: Long Li <longli@microsoft.com>
>>>> ---
>>>>  drivers/scsi/storvsc_drv.c | 16 ++++++++++++++--
>>>>  1 file changed, 14 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
>>>> index b89269120a2d..26c16d40ec46 100644
>>>> --- a/drivers/scsi/storvsc_drv.c
>>>> +++ b/drivers/scsi/storvsc_drv.c
>>>> @@ -1682,6 +1682,18 @@ static int storvsc_queuecommand(struct
>>>Scsi_Host *host, struct scsi_cmnd *scmnd)
>>>>         return 0;
>>>>  }
>>>>
>>>> +static int storvsc_map_queues(struct Scsi_Host *shost) {
>>>> +       unsigned int cpu;
>>>> +       struct blk_mq_queue_map *qmap =
>>>> +&shost->tag_set.map[HCTX_TYPE_DEFAULT];
>>>> +
>>>> +       for_each_possible_cpu(cpu) {
>>>> +               qmap->mq_map[cpu] = cpu;
>>>> +       }
>>>
>>>Block layer provides the helper of blk_mq_map_queues(), so suggest you
>>>to use the default cpu mapping, instead of inventing a new one.

Thanks for the pointer. I'm sending a v2.

Long

>>>
>>>thanks,
>>>Ming Lei

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

end of thread, other threads:[~2019-08-22 19:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 19:35 [PATCH] storvsc: setup 1:1 mapping between hardware queue and CPU queue longli
2019-08-22 10:55 ` Ming Lei
2019-08-22 19:31   ` Long Li

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