Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1038019ybt; Wed, 8 Jul 2020 19:09:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+GOHUhfHuuSZGfOSFhJ/S3OK6/8gTvZ/81+HL1ll+L0EBRHAyJfzTKNalhLKAa7T5obDG X-Received: by 2002:a17:906:8392:: with SMTP id p18mr57585371ejx.24.1594260542408; Wed, 08 Jul 2020 19:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594260542; cv=none; d=google.com; s=arc-20160816; b=xc0ewnM1Co0J9aMGj6b0FR0CBjEQomFwnnmPQj/gZa1sokq/FVJ9e1k0rUUN8TzGnV QtZCmmmoZf+PGW7HNTs7SH3GOkC3u4ibZEsLtTKAJ1xAkEFKJ9rSUuRMb7IG7LcCXvcE ymX0apaqILvHMMAr//8jOa8pmk0erVyJeOYERt1YL/sKw9ACNh61BPxSookKUUFtoh4e 5dQFt+DzS5LmyplqYK3Z0mK7wq9T72UZFBKA4ceKe8q+YUjcqMBWpMhbXG0s5Ya+lu18 VA9SVd2mCU8wn8EhR8gvO2xyBeJpvvz0yk4l+r85J+K4RZNNnxyWP/s2dqBnbNOuwahv 3GDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=FxW9fLawG1R4Bll/dmuJxXRwv1Wu1DJvcLieuVjpu2I=; b=Us3tTYf0I20RLhTs0q+ej7qjyMWbBIT+mQPf7GPWRt9nszkzdvKD/JaLMYJMuNgCan NdfeKERMtPGd1/S3cB4v2frc/2V0h+uQqzGHnwnrO/LhjGuNWGLEWbyks76iqwfitNJB 4+PQsig3L2RK3GI5hlftyqmTbP6K1Df1HSPbNW/aeZ4JlMoWDNyJ+SRa9grs+zpLAspT AUFMLy54oDUdgmKRSKQpdqEUpHrBuKnRIJHsfNMuArGvWwtgXXfkvIQDD3v6ldcJHG5N 7Zuxa47La+CiKtRmuieY/BWqUnFsNSDjr0R/J1QB4raJX5kARdja+Hl5MpKDyL51CrWj wvZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m8si1024632edv.543.2020.07.08.19.08.39; Wed, 08 Jul 2020 19:09:02 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbgGICHh (ORCPT + 99 others); Wed, 8 Jul 2020 22:07:37 -0400 Received: from foss.arm.com ([217.140.110.172]:52636 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbgGICHh (ORCPT ); Wed, 8 Jul 2020 22:07:37 -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 3574311FB; Wed, 8 Jul 2020 19:07:36 -0700 (PDT) Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com [10.169.212.213]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 67D5A3F887; Wed, 8 Jul 2020 19:07:26 -0700 (PDT) From: Jia He To: Catalin Marinas , Will Deacon , Tony Luck , Fenghua Yu , Yoshinori Sato , Rich Felker , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , David Hildenbrand Cc: x86@kernel.org, "H. Peter Anvin" , Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , Baoquan He , Chuhong Yuan , Mike Rapoport , Logan Gunthorpe , Masahiro Yamada , Michal Hocko , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org, Jonathan Cameron , Kaly Xin , Jia He Subject: [PATCH v3 5/6] device-dax: use fallback nid when numa_node is invalid Date: Thu, 9 Jul 2020 10:06:28 +0800 Message-Id: <20200709020629.91671-6-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709020629.91671-1-justin.he@arm.com> References: <20200709020629.91671-1-justin.he@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org numa_off is set unconditionally at the end of dummy_numa_init(), even with a fake numa node. ACPI detects node id as NUMA_NO_NODE(-1) in 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. Without this patch, pmem can't be probed as a RAM device 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 --- drivers/dax/kmem.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index 275aa5f87399..218f66057994 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -31,22 +31,23 @@ int dev_dax_kmem_probe(struct device *dev) int numa_node; int rc; + /* Hotplug starting at the beginning of the next block: */ + kmem_start = ALIGN(res->start, memory_block_size_bytes()); + /* * 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. + * unavoidable performance issues. Furthermore, fallback node + * id can be used when numa_node is invalid. */ numa_node = dev_dax->target_node; if (numa_node < 0) { - dev_warn(dev, "rejecting DAX region %pR with invalid node: %d\n", - res, numa_node); - return -EINVAL; + numa_node = memory_add_physaddr_to_nid(kmem_start); + dev_info(dev, "using nid %d for DAX region with undefined nid %pR\n", + numa_node, res); } - /* Hotplug starting at the beginning of the next block: */ - kmem_start = ALIGN(res->start, memory_block_size_bytes()); - kmem_size = resource_size(res); /* Adjust the size down to compensate for moving up kmem_start: */ kmem_size -= kmem_start - res->start; @@ -100,15 +101,19 @@ static int dev_dax_kmem_remove(struct device *dev) resource_size_t kmem_start = res->start; resource_size_t kmem_size = resource_size(res); const char *res_name = res->name; + int numa_node = dev_dax->target_node; int rc; + if (numa_node < 0) + numa_node = memory_add_physaddr_to_nid(kmem_start); + /* * We have one shot for removing memory, if some memory blocks were not * offline prior to calling this function remove_memory() will fail, and * there is no way to hotremove this memory until reboot because device * unbind will succeed even if we return failure. */ - rc = remove_memory(dev_dax->target_node, kmem_start, kmem_size); + rc = remove_memory(numa_node, kmem_start, kmem_size); if (rc) { any_hotremove_failed = true; dev_err(dev, -- 2.17.1