All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: core: Refine how we set tag_set NUMA node
@ 2022-03-22  8:57 John Garry
  2022-03-22 15:53 ` John Garry
  0 siblings, 1 reply; 2+ messages in thread
From: John Garry @ 2022-03-22  8:57 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, hch, ming.lei, bvanassche, John Garry

For SCSI hosts which enable host_tagset the NUMA node returned from
blk_mq_hw_queue_to_node() is NUMA_NO_NODE always. Then, since in
scsi_mq_setup_tags() the default we choose for the tag_set NUMA node is
NUMA_NO_NODE, we always evaluate the NUMA node as NUMA_NO_NODE in
functions like blk_mq_alloc_rq_map().

The reason we get NUMA_NO_NODE from blk_mq_hw_queue_to_node() is that
the hctx_idx passed is BLK_MQ_NO_HCTX_IDX - so we can't match against a
(HW) queue mapping index.

Improve this by defaulting the tag_set NUMA node to the same NUMA node
of the SCSI host DMA dev.

Signed-off-by: John Garry <john.garry@huawei.com>

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index f69b77cbf538..8352f90d997d 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -229,10 +229,6 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
 	if (error)
 		goto fail;
 
-	error = scsi_mq_setup_tags(shost);
-	if (error)
-		goto fail;
-
 	if (!shost->shost_gendev.parent)
 		shost->shost_gendev.parent = dev ? dev : &platform_bus;
 	if (!dma_dev)
@@ -240,6 +236,10 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
 
 	shost->dma_dev = dma_dev;
 
+	error = scsi_mq_setup_tags(shost);
+	if (error)
+		goto fail;
+
 	/*
 	 * Increase usage count temporarily here so that calling
 	 * scsi_autopm_put_host() will trigger runtime idle if there is
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0a70aa763a96..7faa83b89fa4 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1982,7 +1982,11 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
 	tag_set->nr_maps = shost->nr_maps ? : 1;
 	tag_set->queue_depth = shost->can_queue;
 	tag_set->cmd_size = cmd_size;
+	#ifdef CONFIG_NUMA
+	tag_set->numa_node = shost->dma_dev->numa_node;
+	#else
 	tag_set->numa_node = NUMA_NO_NODE;
+	#endif
 	tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
 	tag_set->flags |=
 		BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);
-- 
2.26.2


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

* Re: [PATCH] scsi: core: Refine how we set tag_set NUMA node
  2022-03-22  8:57 [PATCH] scsi: core: Refine how we set tag_set NUMA node John Garry
@ 2022-03-22 15:53 ` John Garry
  0 siblings, 0 replies; 2+ messages in thread
From: John Garry @ 2022-03-22 15:53 UTC (permalink / raw)
  To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, hch, ming.lei, bvanassche

On 22/03/2022 08:57, John Garry wrote:
>   	/*
>   	 * Increase usage count temporarily here so that calling
>   	 * scsi_autopm_put_host() will trigger runtime idle if there is
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 0a70aa763a96..7faa83b89fa4 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1982,7 +1982,11 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
>   	tag_set->nr_maps = shost->nr_maps ? : 1;
>   	tag_set->queue_depth = shost->can_queue;
>   	tag_set->cmd_size = cmd_size;
> +	#ifdef CONFIG_NUMA
> +	tag_set->numa_node = shost->dma_dev->numa_node;
> +	#else
>   	tag_set->numa_node = NUMA_NO_NODE;
> +	#endif

note to self: use dev_to_node()

>   	tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
>   	tag_set->flags |=


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

end of thread, other threads:[~2022-03-22 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22  8:57 [PATCH] scsi: core: Refine how we set tag_set NUMA node John Garry
2022-03-22 15:53 ` John Garry

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.