Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1427053pxb; Fri, 10 Sep 2021 05:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYYpiJ/jir4k3E2G/bMMoMofOBHJ+8TVwN/Kkyo63z3eSFYUVUYzsYGacbwjr2i8+T0IBd X-Received: by 2002:a17:907:100c:: with SMTP id ox12mr9402814ejb.102.1631278259077; Fri, 10 Sep 2021 05:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631278259; cv=none; d=google.com; s=arc-20160816; b=GKaB4jYxRSSIKR8dCEVO+6cLpUOnxj8YsenmCG9QY0SPfLaeXZ5cfjxZ4m0h+XbHSF rG1I/Wl8rwejrgY96SMkf7uXdTRNNRDODU2uGzg8qJE7RQb+jxxCfeHYBvqyzTC2zjkD 2cOS2yv89QfBF/w+RZ2tn6b8u9u1rSqv4olSjV47+7swRSpU2vMQLfZZSCLvrcI0OgOS LzrZZG9hQwFcf0JDxmbWIjA6Ee2B5FXYqpgSOrJ+YsLL7YhbIwBhyKQY6xLLf++hrgx+ 3fukjMSVC3zNAJRRnUl6fySkqxLWO93MyssG+W6l+FBmWrLOmRSfCWTVdhg6haW7CfSa LhTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=6YgH3D2eyNZYhOEFcFAo+hDbYNkBZpWr/1L0AJ+2hS0=; b=nGSIQW3pmQoEofYuQl4OBT2eJBEwmqi91XpRTfaoXkBAkXRK/6gFLrSphKC3V4DPI/ w2SYsNpqVkySX/BUEsAGMmyRnymfUgZhOzqwBWW/LJ04WcWTzSELdT7xmZImc5uo4tzA A9kc5fFnHcjTg5hAYsWvErCfAx5R2xoLofEyQMha4mniTbdxKu+nB2VpOu52IvQHOPs6 APqhXobXAj+qjuZS183uAMEI8mwgl0g7SHG3MTX0lKXQPourVtK0T7iD1ooE7TWsor9S pFgI/+yd2hX9pWU9J3eYpn8EmtZRVBV2v+1cWiBALgrUNgZNRWGY1StNbSPaLdRiT6nw W7Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si6682445ejn.606.2021.09.10.05.50.35; Fri, 10 Sep 2021 05:50:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233130AbhIJMru (ORCPT + 99 others); Fri, 10 Sep 2021 08:47:50 -0400 Received: from foss.arm.com ([217.140.110.172]:56680 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231843AbhIJMrt (ORCPT ); Fri, 10 Sep 2021 08:47:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66B256D; Fri, 10 Sep 2021 05:46:38 -0700 (PDT) Received: from entos-ampere-02.shanghai.arm.com (entos-ampere-02.shanghai.arm.com [10.169.214.103]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 10A973F5A1; Fri, 10 Sep 2021 05:46:35 -0700 (PDT) From: Jia He To: Dan Williams , Vishal Verma , Dave Jiang , David Hildenbrand Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, Jia He Subject: [PATCH v2] device-dax: use fallback nid when numa node is invalid Date: Fri, 10 Sep 2021 20:46:28 +0800 Message-Id: <20210910124628.6261-1-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously, numa_off was set unconditionally in dummy_numa_init() even with a fake numa node. Then ACPI sets node id as NUMA_NO_NODE(-1) after acpi_map_pxm_to_node() because it regards numa_off as turning off the numa node. Hence dev_dax->target_node is NUMA_NO_NODE on arm64 with fake numa case. Without this patch, pmem can't be probed as RAM devices on arm64 if SRAT table isn't present: $ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g -a 64K kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with invalid node: -1 kmem: probe of dax0.0 failed with error -22 This fixes it by using fallback memory_add_physaddr_to_nid() as nid. Suggested-by: David Hildenbrand Signed-off-by: Jia He --- v2: - rebase it based on David's "memory group" patch. - drop the changes in dev_dax_kmem_remove() since nid had been removed in remove_memory(). drivers/dax/kmem.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index a37622060fff..e4836eb7539e 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -47,20 +47,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) unsigned long total_len = 0; struct dax_kmem_data *data; int i, rc, mapped = 0; - int numa_node; - - /* - * Ensure good NUMA information for the persistent memory. - * Without this check, there is a risk that slow memory - * could be mixed in a node with faster memory, causing - * unavoidable performance issues. - */ - numa_node = dev_dax->target_node; - if (numa_node < 0) { - dev_warn(dev, "rejecting DAX region with invalid node: %d\n", - numa_node); - return -EINVAL; - } + int numa_node = dev_dax->target_node; for (i = 0; i < dev_dax->nr_range; i++) { struct range range; @@ -71,6 +58,22 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) i, range.start, range.end); continue; } + + /* + * Ensure good NUMA information for the persistent memory. + * Without this check, there is a risk but not fatal that slow + * memory could be mixed in a node with faster memory, causing + * unavoidable performance issues. Warn this and use fallback + * node id. + */ + if (numa_node < 0) { + int new_node = memory_add_physaddr_to_nid(range.start); + + dev_info(dev, "changing nid from %d to %d for DAX region [%#llx-%#llx]\n", + numa_node, new_node, range.start, range.end); + numa_node = new_node; + } + total_len += range_len(&range); } -- 2.17.1