Hi, Yuquan, On Wed, Apr 9, 2025 at 3:03 PM Yuquan Wang <wangyuquan1236@xxxxxxxxxxxxxx> wrote: > > "mm: introduce numa_memblks"(87482708210f) has moved numa_memblks > from x86 to the generic code, but loongarch was left out of this > conversion. > > This patch introduces the generic numa_memblks. Thank you for your patch, but it cause many errors: loongarch64-linux-ld: mm/numa_memblks.o: in function `memory_add_physaddr_to_nid': numa_memblks.c:(.text+0x60): multiple definition of `memory_add_physaddr_to_nid'; arch/loongarch/mm/init.o:init.c:(.text+0x0): first defined here loongarch64-linux-ld: mm/numa_memblks.o: in function `numa_set_distance': numa_memblks.c:(.init.text+0x248): multiple definition of `numa_set_distance'; arch/loongarch/kernel/acpi.o:acpi.c:(.init.text+0x534): first defined here loongarch64-linux-ld: mm/numa_memblks.o: in function `.LANCHOR2': numa_memblks.c:(.init.data+0x0): multiple definition of `numa_nodes_parsed'; arch/loongarch/kernel/numa.o:numa.c:(.init.data+0x0): first defined here make[2]: *** [scripts/Makefile.vmlinux_o:72:vmlinux.o] 错误 1 make[1]: *** [/home/chenhuacai/linux-official.git/Makefile:1223:vmlinux_o] 错误 2 make: *** [Makefile:248:__sub-make] 错误 2 INSTALL /home/chenhuacai/dest/lib/modules/6.15.0-rc1+/vdso/vdso.so It cannot be fixed easily, but I will try my best to do that based on your patch. Huacai > > Signed-off-by: Yuquan Wang <wangyuquan1236@xxxxxxxxxxxxxx> > --- > > Background > ---------- > I am managed to land the patch[1] "mm: numa_memblks: introduce numa_add_reserved_memblk" > but kernel test CI noticed build errors[2] from loongarch64-linux-gcc. > > Link: > [1]: https://lore.kernel.org/all/20250409040121.3212489-1-wangyuquan1236@xxxxxxxxxxxxxx/ > [2]: https://lore.kernel.org/all/202503282026.QNaOAK79-lkp@xxxxxxxxx/ > > arch/loongarch/Kconfig | 1 + > arch/loongarch/include/asm/numa.h | 14 ---------- > arch/loongarch/kernel/numa.c | 43 +------------------------------ > 3 files changed, 2 insertions(+), 56 deletions(-) > > diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig > index 067c0b994648..5906ccd06705 100644 > --- a/arch/loongarch/Kconfig > +++ b/arch/loongarch/Kconfig > @@ -186,6 +186,7 @@ config LOONGARCH > select MODULES_USE_ELF_RELA if MODULES > select NEED_PER_CPU_EMBED_FIRST_CHUNK > select NEED_PER_CPU_PAGE_FIRST_CHUNK > + select NUMA_MEMBLKS > select OF > select OF_EARLY_FLATTREE > select PCI > diff --git a/arch/loongarch/include/asm/numa.h b/arch/loongarch/include/asm/numa.h > index b5f9de9f102e..bbf9f70bd25f 100644 > --- a/arch/loongarch/include/asm/numa.h > +++ b/arch/loongarch/include/asm/numa.h > @@ -22,20 +22,6 @@ extern int numa_off; > extern s16 __cpuid_to_node[CONFIG_NR_CPUS]; > extern nodemask_t numa_nodes_parsed __initdata; > > -struct numa_memblk { > - u64 start; > - u64 end; > - int nid; > -}; > - > -#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) > -struct numa_meminfo { > - int nr_blks; > - struct numa_memblk blk[NR_NODE_MEMBLKS]; > -}; > - > -extern int __init numa_add_memblk(int nodeid, u64 start, u64 end); > - > extern void __init early_numa_add_cpu(int cpuid, s16 node); > extern void numa_add_cpu(unsigned int cpu); > extern void numa_remove_cpu(unsigned int cpu); > diff --git a/arch/loongarch/kernel/numa.c b/arch/loongarch/kernel/numa.c > index 30a72fd528c0..0ed384635566 100644 > --- a/arch/loongarch/kernel/numa.c > +++ b/arch/loongarch/kernel/numa.c > @@ -18,6 +18,7 @@ > #include <linux/efi.h> > #include <linux/irq.h> > #include <linux/pci.h> > +#include <linux/numa_memblks.h> > #include <asm/bootinfo.h> > #include <asm/loongson.h> > #include <asm/numa.h> > @@ -145,48 +146,6 @@ void numa_remove_cpu(unsigned int cpu) > cpumask_clear_cpu(cpu, &cpus_on_node[nid]); > } > > -static int __init numa_add_memblk_to(int nid, u64 start, u64 end, > - struct numa_meminfo *mi) > -{ > - /* ignore zero length blks */ > - if (start == end) > - return 0; > - > - /* whine about and ignore invalid blks */ > - if (start > end || nid < 0 || nid >= MAX_NUMNODES) { > - pr_warn("NUMA: Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n", > - nid, start, end - 1); > - return 0; > - } > - > - if (mi->nr_blks >= NR_NODE_MEMBLKS) { > - pr_err("NUMA: too many memblk ranges\n"); > - return -EINVAL; > - } > - > - mi->blk[mi->nr_blks].start = PFN_ALIGN(start); > - mi->blk[mi->nr_blks].end = PFN_ALIGN(end - PAGE_SIZE + 1); > - mi->blk[mi->nr_blks].nid = nid; > - mi->nr_blks++; > - return 0; > -} > - > -/** > - * numa_add_memblk - Add one numa_memblk to numa_meminfo > - * @nid: NUMA node ID of the new memblk > - * @start: Start address of the new memblk > - * @end: End address of the new memblk > - * > - * Add a new memblk to the default numa_meminfo. > - * > - * RETURNS: > - * 0 on success, -errno on failure. > - */ > -int __init numa_add_memblk(int nid, u64 start, u64 end) > -{ > - return numa_add_memblk_to(nid, start, end, &numa_meminfo); > -} > - > static void __init node_mem_init(unsigned int node) > { > unsigned long start_pfn, end_pfn; > -- > 2.34.1 > >