Skip to contentSkip to conversation

storvsc: setup 1:1 mapping between hardware queue and CPU queue

PATCH Superseded [email protected] 3 participants 3 messages Aug 19, 2019 – Aug 22, 2019

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 storvsc: setup 1:1 mapping between hardware queue and CPU queue

From: Long Li <[email protected]>

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.

---
 drivers/scsi/storvsc_drv.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/scsi/storvsc_drv.c +14 -2
index b89269120a2d..26c16d40ec46 100644
@@ -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.
Signature · 1 line
2.17.1
#1 lore raw
Quoted 21 lines · On Tue, Aug 20, 2019 at 3:36 AM <[email protected]> wrote:

From: Long Li <[email protected]>

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.

---
 drivers/scsi/storvsc_drv.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/scsi/storvsc_drv.c +0 -0
index b89269120a2d..26c16d40ec46 100644
@@ -1682,6 +1682,18 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
        return 0;

drivers/scsi/storvsc_drv.c static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) · line 1692

Quoted 10 lines
drivers/scsi/storvsc_drv.c +8 -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

#2 lore raw
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

Subject: Re: [PATCH] storvsc: setup 1:1 mapping between hardware queue and CPU queue

Quoted 8 lines · On Tue, Aug 20, 2019 at 3:36 AM <[email protected]> wrote:

From: Long Li <[email protected]>

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,

drivers/scsi/storvsc_drv.c static int storvsc_queuecommand(struct

Quoted 12 lines

thus avoiding unnecessary locking at upper layer when issuing I/O.

---
 drivers/scsi/storvsc_drv.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/scsi/storvsc_drv.c +0 -0
index b89269120a2d..26c16d40ec46 100644
@@ -1682,6 +1682,18 @@ static int storvsc_queuecommand(struct

Scsi_Host *host, struct scsi_cmnd *scmnd)

Quoted 3 lines
drivers/scsi/storvsc_drv.c +0 -0
        return 0;
 }
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/scsi/storvsc_drv.c static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) · line 1692

Quoted 8 lines
drivers/scsi/storvsc_drv.c +8 -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

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

thanks,
Ming Lei