mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-23 04:04:26 +08:00
mm: make range-to-target_node lookup facility a part of numa_memblks
The x86 implementation of range-to-target_node lookup (i.e. phys_to_target_node() and memory_add_physaddr_to_nid()) relies on numa_memblks. Since numa_memblks are now part of the generic code, move these functions from x86 to mm/numa_memblks.c and select CONFIG_NUMA_KEEP_MEMINFO when CONFIG_NUMA_MEMBLKS=y for dax and cxl. [rppt@kernel.org: fix build] Link: https://lkml.kernel.org/r/ZtVfSt_zloPdDqVB@kernel.org Link: https://lkml.kernel.org/r/20240807064110.1003856-26-rppt@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Tested-by: Zi Yan <ziy@nvidia.com> # for x86_64 and arm64 Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> [arm64 + CXL via QEMU] Reviewed-by: Dan Williams <dan.j.williams@intel.com> Acked-by: David Hildenbrand <david@redhat.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Andreas Larsson <andreas@gaisler.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Borislav Petkov <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: David S. Miller <davem@davemloft.net> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Rafael J. Wysocki <rafael@kernel.org> Cc: Rob Herring (Arm) <robh@kernel.org> Cc: Samuel Holland <samuel.holland@sifive.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
767507654c
commit
1b5695b024
@ -31,13 +31,4 @@
|
||||
|
||||
#endif /* CONFIG_SPARSEMEM */
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef CONFIG_NUMA_KEEP_MEMINFO
|
||||
extern int phys_to_target_node(phys_addr_t start);
|
||||
#define phys_to_target_node phys_to_target_node
|
||||
extern int memory_add_physaddr_to_nid(u64 start);
|
||||
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
|
||||
#endif
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* _ASM_X86_SPARSEMEM_H */
|
||||
|
@ -453,41 +453,3 @@ u64 __init numa_emu_dma_end(void)
|
||||
return PFN_PHYS(MAX_DMA32_PFN);
|
||||
}
|
||||
#endif /* CONFIG_NUMA_EMU */
|
||||
|
||||
#ifdef CONFIG_NUMA_KEEP_MEMINFO
|
||||
static int meminfo_to_nid(struct numa_meminfo *mi, u64 start)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mi->nr_blks; i++)
|
||||
if (mi->blk[i].start <= start && mi->blk[i].end > start)
|
||||
return mi->blk[i].nid;
|
||||
return NUMA_NO_NODE;
|
||||
}
|
||||
|
||||
int phys_to_target_node(phys_addr_t start)
|
||||
{
|
||||
int nid = meminfo_to_nid(&numa_meminfo, start);
|
||||
|
||||
/*
|
||||
* Prefer online nodes, but if reserved memory might be
|
||||
* hot-added continue the search with reserved ranges.
|
||||
*/
|
||||
if (nid != NUMA_NO_NODE)
|
||||
return nid;
|
||||
|
||||
return meminfo_to_nid(&numa_reserved_meminfo, start);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(phys_to_target_node);
|
||||
|
||||
int memory_add_physaddr_to_nid(u64 start)
|
||||
{
|
||||
int nid = meminfo_to_nid(&numa_meminfo, start);
|
||||
|
||||
if (nid == NUMA_NO_NODE)
|
||||
nid = numa_meminfo.blk[0].nid;
|
||||
return nid;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
|
||||
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@ menuconfig CXL_BUS
|
||||
select FW_UPLOAD
|
||||
select PCI_DOE
|
||||
select FIRMWARE_TABLE
|
||||
select NUMA_KEEP_MEMINFO if (NUMA && X86)
|
||||
select NUMA_KEEP_MEMINFO if NUMA_MEMBLKS
|
||||
help
|
||||
CXL is a bus that is electrically compatible with PCI Express, but
|
||||
layers three protocols on that signalling (CXL.io, CXL.cache, and
|
||||
|
@ -30,7 +30,7 @@ config DEV_DAX_PMEM
|
||||
config DEV_DAX_HMEM
|
||||
tristate "HMEM DAX: direct access to 'specific purpose' memory"
|
||||
depends on EFI_SOFT_RESERVE
|
||||
select NUMA_KEEP_MEMINFO if (NUMA && X86)
|
||||
select NUMA_KEEP_MEMINFO if NUMA_MEMBLKS
|
||||
default DEV_DAX
|
||||
help
|
||||
EFI 2.8 platforms, and others, may advertise 'specific purpose'
|
||||
|
@ -46,6 +46,13 @@ static inline int numa_emu_cmdline(char *str)
|
||||
}
|
||||
#endif /* CONFIG_NUMA_EMU */
|
||||
|
||||
#ifdef CONFIG_NUMA_KEEP_MEMINFO
|
||||
extern int phys_to_target_node(u64 start);
|
||||
#define phys_to_target_node phys_to_target_node
|
||||
extern int memory_add_physaddr_to_nid(u64 start);
|
||||
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
|
||||
#endif /* CONFIG_NUMA_KEEP_MEMINFO */
|
||||
|
||||
#endif /* CONFIG_NUMA_MEMBLKS */
|
||||
|
||||
#endif /* __NUMA_MEMBLKS_H */
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <linux/memblock.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/numa.h>
|
||||
#include <linux/numa_memblks.h>
|
||||
|
||||
struct pglist_data *node_data[MAX_NUMNODES];
|
||||
EXPORT_SYMBOL(node_data);
|
||||
|
@ -531,3 +531,41 @@ int __init numa_fill_memblks(u64 start, u64 end)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NUMA_KEEP_MEMINFO
|
||||
static int meminfo_to_nid(struct numa_meminfo *mi, u64 start)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mi->nr_blks; i++)
|
||||
if (mi->blk[i].start <= start && mi->blk[i].end > start)
|
||||
return mi->blk[i].nid;
|
||||
return NUMA_NO_NODE;
|
||||
}
|
||||
|
||||
int phys_to_target_node(u64 start)
|
||||
{
|
||||
int nid = meminfo_to_nid(&numa_meminfo, start);
|
||||
|
||||
/*
|
||||
* Prefer online nodes, but if reserved memory might be
|
||||
* hot-added continue the search with reserved ranges.
|
||||
*/
|
||||
if (nid != NUMA_NO_NODE)
|
||||
return nid;
|
||||
|
||||
return meminfo_to_nid(&numa_reserved_meminfo, start);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(phys_to_target_node);
|
||||
|
||||
int memory_add_physaddr_to_nid(u64 start)
|
||||
{
|
||||
int nid = meminfo_to_nid(&numa_meminfo, start);
|
||||
|
||||
if (nid == NUMA_NO_NODE)
|
||||
nid = numa_meminfo.blk[0].nid;
|
||||
return nid;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
|
||||
|
||||
#endif /* CONFIG_NUMA_KEEP_MEMINFO */
|
||||
|
Loading…
Reference in New Issue
Block a user