From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBE31C4345F for ; Tue, 16 Apr 2024 08:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=/KlrGriDdpu2QY5zei8AfQFRVV7Nz1+Bh3PMvV2S0bM=; b=MrVqr2fgozvnUY DsFoVrsp6RTKjIESnRfAbX/JRoKoST/JRRJzfXqISpY0nY7fu2evhRZDcQZpN073G0XJ9CkTUkrya qhRJuoAswRWHewrUNgjQwXJTanrNCZpn9n94FelNf5nqJ/jn9T+hwrq4RXDjVUlgasqq62hCAESYA bIEyZA7yNvYStPyAtppoUodKAT8U9WtyTuGqlDazYdhQ5qG6FAn/INXvbaHvfcINe96FnpF56JGMn WwG2mawNBTQS9nB1rjyFTtufP1lw/nwn31+Z7uBp0mN8t/3vuGsics9srlhkl3LAdXlsY+IBTd83s uD0dQrB038fHRut+jdNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwe56-0000000BQgw-0uoq; Tue, 16 Apr 2024 08:22:20 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwe51-0000000BQfy-3bgo for linux-nvme@lists.infradead.org; Tue, 16 Apr 2024 08:22:18 +0000 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43G8EHc6004306; Tue, 16 Apr 2024 08:22:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=/KlrGriDdpu2QY5zei8AfQFRVV7Nz1+Bh3PMvV2S0bM=; b=thNA5tdrAMGkANfsIOrK+NwZxkHb02Akus5+jxltPat/godi/X++rwaiBBAbwnSv7DCJ w1GSdaqAM4uJ69DR/hWE4725Z7F4NyOaeuCzo/Q5qr7GiT+Ajrw4Zjpr26c7hJb/fwn4 cpH7XxQt2HVo+0PwzwUwI3dc1oZ1s0gZ8th/aIzUNbwkiCQGFEK8zoyOKoPGW+X5HzFa YaTalxeO7dw4Mqf0vbjEfcmBIOQS1UzjQtg3JnAJxt+1zGWspVXn8LmUL/nfNl3BB8MY D8axD/nbgYeKEdWFBrVjF+ILntBbUTXYyv33tQE7nMCOE/E1ynlZUPljbGvBn2urAwCY 1g== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xhnmrr0mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Apr 2024 08:22:04 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43G82dar027289; Tue, 16 Apr 2024 08:22:03 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xg4ryw4vh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Apr 2024 08:22:03 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43G8LwI550331936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Apr 2024 08:22:00 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 293AB2004B; Tue, 16 Apr 2024 08:21:58 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 269BE20040; Tue, 16 Apr 2024 08:21:56 +0000 (GMT) Received: from li-c9696b4c-3419-11b2-a85c-f9edc3bf8a84.in.ibm.com (unknown [9.109.198.231]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 16 Apr 2024 08:21:55 +0000 (GMT) From: Nilay Shroff To: linux-nvme@lists.infradead.org Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me, gjoyce@linux.ibm.com, axboe@fb.com, chaitanyak@nvidia.com, Nilay Shroff Subject: [PATCHv3] nvme: find numa distance only if controller has valid numa id Date: Tue, 16 Apr 2024 13:49:23 +0530 Message-ID: <20240416082102.914152-1-nilay@linux.ibm.com> X-Mailer: git-send-email 2.44.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: -faHv-dancq-g0rk0N7OIsnSzLtW_efs X-Proofpoint-GUID: -faHv-dancq-g0rk0N7OIsnSzLtW_efs Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-16_06,2024-04-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 clxscore=1011 spamscore=0 impostorscore=0 suspectscore=0 mlxlogscore=663 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404160050 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240416_012216_042379_3343E96C X-CRM114-Status: GOOD ( 16.97 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org 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 --- 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