Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/memory_hotplug: introduce default phys_to_target_node() implementation

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.

[akpm@linux-foundation.org: fix CONFIG_MEMORY_HOTPLUG=n build]
Link: https://lkml.kernel.org/r/202008252130.7YrHIyMI%25lkp@intel.com

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Jia He <justin.he@arm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brice Goglin <Brice.Goglin@inria.fr>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jason Gunthorpe <jgg@mellanox.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Hulk Robot <hulkci@huawei.com>
Cc: Jason Yan <yanaijie@huawei.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: kernel test robot <lkp@intel.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Link: https://lkml.kernel.org/r/159643097768.4062302.3135192588966888630.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dan Williams and committed by
Linus Torvalds
a035b6bf 73fb952d

+23 -22
-1
arch/x86/mm/numa.c
··· 917 917 918 918 return meminfo_to_nid(&numa_reserved_meminfo, start); 919 919 } 920 - EXPORT_SYMBOL_GPL(phys_to_target_node); 921 920 922 921 int memory_add_physaddr_to_nid(u64 start) 923 922 {
+14 -9
include/linux/memory_hotplug.h
··· 149 149 struct mhp_params *params); 150 150 #endif /* ARCH_HAS_ADD_PAGES */ 151 151 152 - #ifdef CONFIG_NUMA 153 - extern int memory_add_physaddr_to_nid(u64 start); 154 - #else 155 - static inline int memory_add_physaddr_to_nid(u64 start) 156 - { 157 - return 0; 158 - } 159 - #endif 160 - 161 152 #ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION 162 153 /* 163 154 * For supporting node-hotadd, we have to allocate a new pgdat. ··· 274 283 return false; 275 284 } 276 285 #endif /* ! CONFIG_MEMORY_HOTPLUG */ 286 + 287 + #ifdef CONFIG_NUMA 288 + extern int memory_add_physaddr_to_nid(u64 start); 289 + extern int phys_to_target_node(u64 start); 290 + #else 291 + static inline int memory_add_physaddr_to_nid(u64 start) 292 + { 293 + return 0; 294 + } 295 + static inline int phys_to_target_node(u64 start) 296 + { 297 + return 0; 298 + } 299 + #endif 277 300 278 301 #if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT) 279 302 /*
-11
include/linux/numa.h
··· 23 23 #ifdef CONFIG_NUMA 24 24 /* Generic implementation available */ 25 25 int numa_map_to_online_node(int node); 26 - 27 - /* 28 - * Optional architecture specific implementation, users need a "depends 29 - * on $ARCH" 30 - */ 31 - int phys_to_target_node(phys_addr_t addr); 32 26 #else 33 27 static inline int numa_map_to_online_node(int node) 34 - { 35 - return NUMA_NO_NODE; 36 - } 37 - 38 - static inline int phys_to_target_node(phys_addr_t addr) 39 28 { 40 29 return NUMA_NO_NODE; 41 30 }
+9 -1
mm/memory_hotplug.c
··· 353 353 #ifdef CONFIG_NUMA 354 354 int __weak memory_add_physaddr_to_nid(u64 start) 355 355 { 356 - pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n", 356 + pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n", 357 357 start); 358 358 return 0; 359 359 } 360 360 EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); 361 + 362 + int __weak phys_to_target_node(u64 start) 363 + { 364 + pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n", 365 + start); 366 + return 0; 367 + } 368 + EXPORT_SYMBOL_GPL(phys_to_target_node); 361 369 #endif 362 370 363 371 /* find the smallest valid pfn in the range [start_pfn, end_pfn) */