From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 138761C8FD2; Tue, 7 May 2024 23:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123597; cv=none; b=kwHqd2bJhHQEZGuz3iXNeVChU9coENgwXqMCjrch2ZVWZMjSBfWNME8rlJawsBKY1nyzhelzgjyDbR62lV9hCRdzNJLwdkUnlfZRBR5ZIyrcphMm77DMBVO0RbF8h8kLFL9nxHZ3WOuWJDtpJA4cppr5zPVBmndU4JthXIRFSLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123597; c=relaxed/simple; bh=EKN08DW9s7MzrLgAqdyreXAk1J29WVSlpid6Z3QJLFI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p1ykx203yeE9ByQ0yPoPrigNU34GMFYdNltimbXGlnTEaqxaSxRgye9MepcpAQwjeXcc/z0Vrpvy05/o6A4/zXs/cbJo/cGTLl2bWKGPAsjl5YNwEAtSpIG3vUQpDIMIkAV0oKqEfV42sNHiAqEFkQw7IVigswQFZwMafnGMAvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Aeqz4a1A; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Aeqz4a1A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC1BEC3277B; Tue, 7 May 2024 23:13:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715123596; bh=EKN08DW9s7MzrLgAqdyreXAk1J29WVSlpid6Z3QJLFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aeqz4a1AC2PlBWWpEFEPn6C6yH6g5cQFAPkVWP6olQB84fa0O1Dl57AUNRX7xc1XR zkUTI89BpwyHRzKHYD0FBvGmGMKoGrfJHz1C7+ePfe3z5ObuV43ctXeX+zDqVUEYH+ tctnmr2ialhB1wDL7KflApXOu3zeNjFlTlAt4IhCYbuATmIqwPtI0s4jrZvg1EsxyI AFwsLcbsAYJ0SOABH/8w4/JbzQ4aFT3ZqsLnrPbjhmGO1iF/VyDXCWbHyT6PfXGdV+ pM6JlE4bVJEwmMzdpp/vI7UmZWyWSLCOp1vQWcYmk8dlU7oCPjx/RWIbFwyjk+iN7D pumfViqVZ9KrA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nilay Shroff , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Keith Busch , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 6.1 20/25] nvme: find numa distance only if controller has valid numa id Date: Tue, 7 May 2024 19:12:07 -0400 Message-ID: <20240507231231.394219-20-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507231231.394219-1-sashal@kernel.org> References: <20240507231231.394219-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.90 Content-Transfer-Encoding: 8bit From: Nilay Shroff [ Upstream commit 863fe60ed27f2c85172654a63c5b827e72c8b2e6 ] 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 Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- 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 f96d330d39641..6cf0ce7aff678 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -213,7 +213,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.43.0