Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp175551lqo; Tue, 7 May 2024 16:44:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwM8pLHDP/H6rO+UHs0VBACOUe5PiedG2rnzydmzXJXo9hH89kfCU8VAeBxgM8sXQHLKtgRXwGclsUvpdtPi94JN3jQDGRGQbZaNwrGg== X-Google-Smtp-Source: AGHT+IE8ZtIhcNmJrgOI6L1vXAB7htk9NQiz5jk6dIofu9xZ5l8ul/UG0MLzfkBzz7R3nWEtFGHF X-Received: by 2002:a9d:745a:0:b0:6f0:8796:2006 with SMTP id 46e09a7af769-6f0b782da9cmr1037784a34.6.1715125471825; Tue, 07 May 2024 16:44:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715125471; cv=pass; d=google.com; s=arc-20160816; b=X/er2Yux3NppHKTbZdp4eWNHKEFf7bjOx3YPvJonpHeomwTuw66PbYFcR3w21wBkQZ HpK5eI/3pSgdbCA2nH3nITQxCty31ZY8bO0nmc6enN056HmWOF/IWirR9+OpuNyjTq6J kQxpaQ/ZGEoZtGHmMSewSNNzn3aj5Y75bnrlUkoXyx1QKVBjStscxSbcwJNgKIOmxJd2 7oF83SAoR+JuL4+jx2tZvq5hX1+HWgkTZlSSjGmn35RIPfGu5prwYjpGPPPscZ4FqP/E c5HPHGnjT2EPLOM4Hq2fjGWQW/HVFJFZIL6Hr7N+bsQYlW2vXKOpJ0KPDBISDyNqUF8T I+Mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nC8DSj4Cp3iNi+xUuS+nKG6RidfbmnWqoQplnTqD4pM=; fh=Wd4Y9NTXmg7LDYmFXa4qJtVUw7SaEMzyrb/mccUb6mo=; b=d/whrjOUdBKnkd8spmEh+LMHkpMuscjT3rV1b8Kmy3AXaIcZRbPV9IVYoGt97+3kJ9 RYfyjYYd54fXsgysYNTeuMDv+igo+WNC7cPQbthBAlgVcpyy95JwOtP5W61vS8iJhuXV 8F1dOPiNpoJnESYNtNAS/0sOdHw99gf3bPGP640sfZQGtx+esiAu+10lX95djoN1hI/f kTPWhl6G6AUkjuWY+XJwyPj+70sHQiaVG3tGRXAhXSkIIzT+B+VcNPxEFx7prW3ENmnz p3HbZvUvW+CpZlUKTtuCgYbUvF1Y6XW15moCYSzomZ+K49IcoRAtnbQE7B1s3jCzGTHn TRSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sCgL8TLt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172432-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172432-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l190-20020a6391c7000000b005f401cc97c8si11273927pge.529.2024.05.07.16.44.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 16:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172432-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sCgL8TLt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172432-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172432-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 77C112821B9 for ; Tue, 7 May 2024 23:43:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4C77137C3D; Tue, 7 May 2024 23:12:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sCgL8TLt" 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 19B421708A7; Tue, 7 May 2024 23:12:02 +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=1715123523; cv=none; b=VuO3Vbtu1IwAWHHdDwnl3LAdgSJJ46TdWprGM58eHaiBlwhYpGJATOXfTzbG4kRI7MRmmJ9vj61Dt2wYjk7MwDcMe1RCl4RFHhFqGnNldFGYVbGoCaKeI7x5CjZO8M+EmstNhgkQgr54GohmDUgS3UQLZg7msDUhhHQYrP0pEFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123523; c=relaxed/simple; bh=BW3sS1jeUTOlQ8ybavzsM9YtTj8gFtolCcVVBcb4G0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DgslZDmuyj5hvyzNEC8Girv969B1gOBVUs725fB+ZqdRxvhjns9BUFC3nYb4EFe0hDMwzdGIt5gmRBF2+lhg7c1ZMMPmyMWb1ajT9OydZSU+4uAZM8iahER/Gk8ceZnO7uoglEIi8/6LY0VZCF8+JryvJBnZNE3iwzoSYxFDPbA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sCgL8TLt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB164C4AF67; Tue, 7 May 2024 23:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715123522; bh=BW3sS1jeUTOlQ8ybavzsM9YtTj8gFtolCcVVBcb4G0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sCgL8TLt9qi2S4jyu7/OFC26vDQH4FJivgTaMqRQQ8UisrgI8lqD/bRXifuSXIO27 3UgYtT+w3KkWE3S1TNbaLTx9Ope5px33iGcdy6UB0d5AJkPtL557RG1uwmbDrq3iSl yNBb1u5rU+pvopne/OHxs60swidLzmdE2GkIIzoTdSbTeQGz7Ykv415sAQp93rkHuG rDW6nxa4V/LhBi8ZX0Fu4S0MkogumRc4r45Le0jRwtCgVIBzts9zE5qpeo4YCqrxsZ aLNI2UYIkqaQRAYprRhl0RlG7deLUP2sqVxzd13keXMTKvH/h4eNPwEhHsL5AnpMkL OZRWoDNwf/Quw== 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.6 37/43] nvme: find numa distance only if controller has valid numa id Date: Tue, 7 May 2024 19:09:58 -0400 Message-ID: <20240507231033.393285-37-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507231033.393285-1-sashal@kernel.org> References: <20240507231033.393285-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.6.30 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 0a88d7bdc5e37..b39553b8378b5 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -246,7 +246,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