Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp171659lqo; Tue, 7 May 2024 16:33:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQN6TS/AQNJJ+hci1xU0KCqoNuCkXssR3m6OVAKQmA94VaBW0zKrqkwHZG6FYz41CvXSLitov7g2PF6LmWZ7jSn1ressXQPRrYM06rVQ== X-Google-Smtp-Source: AGHT+IFi7tN6QMGavwR+axqDJR+WvUYKMiWCKdS74wZjPdlXRhkDJCcahshFCzi39CdTqMYrI3+w X-Received: by 2002:aa7:9ec8:0:b0:6eb:1d5:6e43 with SMTP id d2e1a72fcca58-6f49c21e963mr1176624b3a.11.1715124802700; Tue, 07 May 2024 16:33:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715124802; cv=pass; d=google.com; s=arc-20160816; b=Fqf1QrV2kj+WyZD0/g58em/qfiuIRRoXCxCyrNXV81gZgPgOIZYl6t1Xa88SLPK7sC tMJX6peP+n/tiK4wpXelu31kXQGOBrhB90aSKLLw/YNtlaNGWaT3pilExuKu64LyA7m2 8ExGAC3VGWNsdpCqc0YAmpkeDZ1seEbSD2cjD6rTMkG0lBy2KyR9F3cgjtlLRZaKpAr4 iIT5WiKGDbEFDZdnx4FH+erRYTI+lxzLXWsjZ/75888FCY37BHHvXxKt/3EhW+5QtEPT HQ5vXK9b6F9RsQEM/5N+jLbles4WEJt0TvkgpQHka4XWNpDk5NHEcSoWbtffEKj/Og2n ZAqw== 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=3YZ4qfNGh3AdAjcZclXPVurgt4rVN0eN8g2Qf5OQLoA=; fh=Wd4Y9NTXmg7LDYmFXa4qJtVUw7SaEMzyrb/mccUb6mo=; b=EhAx0wSJp/DUQzKEl4kqXqD9NFW2wCnHLTPWaRy3vw+1OTZ6sIDLCU/Zhv06nSd6HF 5lN9zJwPbidID7ZAT0JeO2IejqVQRkfJXmbAdKsWIwG/YuAh8FFSz5GtYW6dRf4CcEa6 hGMh4GnxhvE34Wb/NC+tcfsKxFm7ZxjEZ5NWpQe0ZVXOr27Wnqk7WKO6LctejQs3Ztl7 em8LFP4cYRhBxe+CWMZLNb7KGaU9fcPyqDu8ufhBy40sdCtiH7m+UWWIApuWjRLr4mtr xUu3mm3Nl9coqvdWqCb+caS0MRFQzyllS4sDH6dxcl854C7TB9zAu0su8IWjzTJ4SseD 91IA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cqo8ySPw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172388-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 206-20020a6301d7000000b005f7515ac97dsi11434286pgb.85.2024.05.07.16.33.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 16:33:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172388-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=Cqo8ySPw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172388-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 58A82280F69 for ; Tue, 7 May 2024 23:33:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D388F1465B5; Tue, 7 May 2024 23:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Cqo8ySPw" 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 030DC146597; Tue, 7 May 2024 23:09:53 +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=1715123393; cv=none; b=VxFgJiTSNe2i49Sp5H/og4ETPle5JkqkWDTJKxl/lHW/1xT1bPY/yRUtu5u292aiTTWfpiHtUF4ast53EfjHasF0EpEU7q51M3I38Pt6m5UwSaGGcJ7aA38gWL9esbpPQyRZPHYLShwIYvNmMFH1X+QFCSokXNef81yoA40l8+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123393; c=relaxed/simple; bh=eReVYF2BCrlIPA5oKYsRheyDizBUKVOYu2q3Y2uoyew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WHJL/li8JTT1aCkC0oznGstAHEB3OfjJixNb8xd+UZj/KhBaEFHtwkXQwgGwMreQEE1BYFdr0gKPmSXdjjJr3aMqKtJbzxk6VXzwucYF1xwH/dfXN+j7mkgc4Vw7kQZJwPAYgC8LGB1UXb61GShwawlPhaStEhKF3W/ycaG16d8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cqo8ySPw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D779CC2BBFC; Tue, 7 May 2024 23:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715123392; bh=eReVYF2BCrlIPA5oKYsRheyDizBUKVOYu2q3Y2uoyew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cqo8ySPwk3C0pG13Dmd+CcADEH/cn+FxaMYKxGqDRKs6SuZmm7Il0g70uW5wsfTFE WSyYIc0bDCdYx8h5seI7L3MP20FaKBwHsTaHwLBrGKWMqRu26GA8QkvAZ+Sj7pTSs2 UClHaOCl+pRDCuWEmOgl/SHCwQJPyqYFLRqEV13WizCtk/ZyDv57V62tsmOIyN8GMY rQSDiQ/I2+UmcJwPh3jX9QWQu8ZWdm0atYIcePiv85/QqbmyoYmatjFhgxdLyiS/qs gqY56CnRzrtu1g9yo5kfZCn/Fv8xvkwy+z2JoWufQr/glGuMzJvlMhN9ftIwiwGJoZ lW/8O6cGd67Jw== 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.8 45/52] nvme: find numa distance only if controller has valid numa id Date: Tue, 7 May 2024 19:07:11 -0400 Message-ID: <20240507230800.392128-45-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507230800.392128-1-sashal@kernel.org> References: <20240507230800.392128-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.8.9 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 74de1e64aeead..75386d3e0f981 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.43.0