Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3] nvme: find numa distance only if controller has valid numa id
@ 2024-04-16  8:19 Nilay Shroff
  2024-04-16  9:07 ` Chaitanya Kulkarni
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nilay Shroff @ 2024-04-16  8:19 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, kbusch, sagi, gjoyce, axboe, chaitanyak, Nilay Shroff

On system where native nvme multipath is configured and iopolicy
is set to numa but the nvme controller numa node id is undefined
or -1 (NUMA_NO_NODE) then avoid calculating node distance for
finding optimal io path. In such case we may access numa distance
table with invalid index and that may potentially refer to incorrect
memory. So this patch ensures that if the nvme controller numa node
id is -1 then instead of calculating node distance for finding optimal
io path, we set the numa node distance of such controller to default 10
(LOCAL_DISTANCE).

Link: https://lore.kernel.org/all/20240413090614.678353-1-nilay@linux.ibm.com/
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
Changes from v2:
	Formatting cleanups to avoid overshooting 80 chars width (Chaitanya)
Changes from v1:
    Formatting cleanups (Christoph)

 drivers/nvme/host/multipath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 5397fb428b24..d16e976ae1a4 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -247,7 +247,8 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node)
 		if (nvme_path_is_disabled(ns))
 			continue;
 
-		if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
+		if (ns->ctrl->numa_node != NUMA_NO_NODE &&
+		    READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
 			distance = node_distance(node, ns->ctrl->numa_node);
 		else
 			distance = LOCAL_DISTANCE;
-- 
2.44.0



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

* Re: [PATCHv3] nvme: find numa distance only if controller has valid numa id
  2024-04-16  8:19 [PATCHv3] nvme: find numa distance only if controller has valid numa id Nilay Shroff
@ 2024-04-16  9:07 ` Chaitanya Kulkarni
  2024-04-16  9:43 ` Sagi Grimberg
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2024-04-16  9:07 UTC (permalink / raw)
  To: Nilay Shroff, linux-nvme@lists.infradead.org
  Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me,
	gjoyce@linux.ibm.com, axboe@fb.com

On 4/16/2024 1:19 AM, Nilay Shroff wrote:
> On system where native nvme multipath is configured and iopolicy
> is set to numa but the nvme controller numa node id is undefined
> or -1 (NUMA_NO_NODE) then avoid calculating node distance for
> finding optimal io path. In such case we may access numa distance
> table with invalid index and that may potentially refer to incorrect
> memory. So this patch ensures that if the nvme controller numa node
> id is -1 then instead of calculating node distance for finding optimal
> io path, we set the numa node distance of such controller to default 10
> (LOCAL_DISTANCE).
> 
> Link:https://lore.kernel.org/all/20240413090614.678353-1-nilay@linux.ibm.com/
> Signed-off-by: Nilay Shroff<nilay@linux.ibm.com>

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



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

* Re: [PATCHv3] nvme: find numa distance only if controller has valid numa id
  2024-04-16  8:19 [PATCHv3] nvme: find numa distance only if controller has valid numa id Nilay Shroff
  2024-04-16  9:07 ` Chaitanya Kulkarni
@ 2024-04-16  9:43 ` Sagi Grimberg
  2024-04-16 15:14 ` Christoph Hellwig
  2024-04-16 16:44 ` Keith Busch
  3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2024-04-16  9:43 UTC (permalink / raw)
  To: Nilay Shroff, linux-nvme; +Cc: hch, kbusch, gjoyce, axboe, chaitanyak

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


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

* Re: [PATCHv3] nvme: find numa distance only if controller has valid numa id
  2024-04-16  8:19 [PATCHv3] nvme: find numa distance only if controller has valid numa id Nilay Shroff
  2024-04-16  9:07 ` Chaitanya Kulkarni
  2024-04-16  9:43 ` Sagi Grimberg
@ 2024-04-16 15:14 ` Christoph Hellwig
  2024-04-16 16:44 ` Keith Busch
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2024-04-16 15:14 UTC (permalink / raw)
  To: Nilay Shroff; +Cc: linux-nvme, hch, kbusch, sagi, gjoyce, axboe, chaitanyak

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

* Re: [PATCHv3] nvme: find numa distance only if controller has valid numa id
  2024-04-16  8:19 [PATCHv3] nvme: find numa distance only if controller has valid numa id Nilay Shroff
                   ` (2 preceding siblings ...)
  2024-04-16 15:14 ` Christoph Hellwig
@ 2024-04-16 16:44 ` Keith Busch
  3 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2024-04-16 16:44 UTC (permalink / raw)
  To: Nilay Shroff; +Cc: linux-nvme, hch, sagi, gjoyce, axboe, chaitanyak

On Tue, Apr 16, 2024 at 01:49:23PM +0530, Nilay Shroff wrote:
> On system where native nvme multipath is configured and iopolicy
> is set to numa but the nvme controller numa node id is undefined
> or -1 (NUMA_NO_NODE) then avoid calculating node distance for
> finding optimal io path. In such case we may access numa distance
> table with invalid index and that may potentially refer to incorrect
> memory. So this patch ensures that if the nvme controller numa node
> id is -1 then instead of calculating node distance for finding optimal
> io path, we set the numa node distance of such controller to default 10
> (LOCAL_DISTANCE).

Thanks, applied to nvme-6.9.


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

end of thread, other threads:[~2024-04-16 16:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16  8:19 [PATCHv3] nvme: find numa distance only if controller has valid numa id Nilay Shroff
2024-04-16  9:07 ` Chaitanya Kulkarni
2024-04-16  9:43 ` Sagi Grimberg
2024-04-16 15:14 ` Christoph Hellwig
2024-04-16 16:44 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox