From patchwork Sat Aug 1 03:25:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 11695743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65726138A for ; Sat, 1 Aug 2020 03:41:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3D4B02083E for ; Sat, 1 Aug 2020 03:41:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D4B02083E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 592428D006D; Fri, 31 Jul 2020 23:41:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 542CF8D0068; Fri, 31 Jul 2020 23:41:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4588B8D006D; Fri, 31 Jul 2020 23:41:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id 2EE5A8D0068 for ; Fri, 31 Jul 2020 23:41:56 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E559F181AEF0B for ; Sat, 1 Aug 2020 03:41:55 +0000 (UTC) X-FDA: 77100600990.12.value14_470514f26f89 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id B6C40180154AB for ; Sat, 1 Aug 2020 03:41:55 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dan.j.williams@intel.com,,RULES_HIT:30054:30064:30075,0,RBL:192.55.52.151:@intel.com:.lbl8.mailshell.net-64.95.201.95 62.18.0.100;04yfawsz6t4ktyayuipjcjnykgucgocgcpm86yy3tb7p8jhrjbpan4iy56gf4sp.mc1si6oxen9j5y8pumxpjht3wohoks984w6s6b1sy4jb5scd1ix3yn9koukjxdj.y-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: value14_470514f26f89 X-Filterd-Recvd-Size: 5158 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Sat, 1 Aug 2020 03:41:53 +0000 (UTC) IronPort-SDR: 9uxCNTB6+7PQocg/Yl2zN9bI0e8Bqbw22X22yS0az30FMFJBXlHDX+4T5gaPx+l7uwLqCTgtV4 D0r96AKFdCgA== X-IronPort-AV: E=McAfee;i="6000,8403,9699"; a="131964199" X-IronPort-AV: E=Sophos;i="5.75,420,1589266800"; d="scan'208";a="131964199" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2020 20:41:52 -0700 IronPort-SDR: J5+oL9gEiI7vege3Ovi/9v7xpYCEboTm9hZtr+gXJdO66m+2rxqdrkMRX7lKZOF9RCQEiNvQEJ c+Flf4FPBDOA== X-IronPort-AV: E=Sophos;i="5.75,420,1589266800"; d="scan'208";a="365776535" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2020 20:41:52 -0700 Subject: [PATCH v3 06/23] mm/memory_hotplug: Introduce default phys_to_target_node() implementation From: Dan Williams To: akpm@linux-foundation.org Cc: David Hildenbrand , Mike Rapoport , Jia He , peterz@infradead.org, vishal.l.verma@intel.com, dave.hansen@linux.intel.com, ard.biesheuvel@linaro.org, vishal.l.verma@intel.com, linux-mm@kvack.org, linux-nvdimm@lists.01.org, joao.m.martins@oracle.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Fri, 31 Jul 2020 20:25:34 -0700 Message-ID: <159625233419.3040297.13342516597848248917.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <159625229779.3040297.11363509688097221416.stgit@dwillia2-desk3.amr.corp.intel.com> References: <159625229779.3040297.11363509688097221416.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 X-Rspamd-Queue-Id: B6C40180154AB X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In preparation to set a fallback value for dev_dax->target_node, introduce generic fallback helpers for phys_to_target_node() A generic implementation based on node-data or memblock was proposed, but as noted by Mike: "Here again, I would prefer to add a weak default for phys_to_target_node() because the "generic" implementation is not really generic. The fallback to reserved ranges is x86 specfic because on x86 most of the reserved areas is not in memblock.memory. AFAIK, no other architecture does this." The info message in the generic memory_add_physaddr_to_nid() implementation is fixed up to properly reflect that memory_add_physaddr_to_nid() communicates "online" node info and phys_to_target_node() indicates "target / to-be-onlined" node info. Cc: David Hildenbrand Cc: Mike Rapoport Cc: Jia He Signed-off-by: Dan Williams Reported-by: kernel test robot Reported-by: kernel test robot --- arch/x86/mm/numa.c | 1 - include/linux/memory_hotplug.h | 5 +++++ mm/memory_hotplug.c | 10 +++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index f3805bbaa784..c62e274d52d0 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -917,7 +917,6 @@ int phys_to_target_node(phys_addr_t start) return meminfo_to_nid(&numa_reserved_meminfo, start); } -EXPORT_SYMBOL_GPL(phys_to_target_node); int memory_add_physaddr_to_nid(u64 start) { diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 375515803cd8..dcdc7d6206d5 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -151,11 +151,16 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, #ifdef CONFIG_NUMA extern int memory_add_physaddr_to_nid(u64 start); +extern int phys_to_target_node(u64 start); #else static inline int memory_add_physaddr_to_nid(u64 start) { return 0; } +static inline int phys_to_target_node(u64 start) +{ + return 0; +} #endif #ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index dcdf3271f87e..426b79adf529 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -353,11 +353,19 @@ int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages, #ifdef CONFIG_NUMA int __weak memory_add_physaddr_to_nid(u64 start) { - pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n", + pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n", start); return 0; } EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); + +int __weak phys_to_target_node(u64 start) +{ + pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n", + start); + return 0; +} +EXPORT_SYMBOL_GPL(phys_to_target_node); #endif /* find the smallest valid pfn in the range [start_pfn, end_pfn) */