diff mbox series

[1/1] LoongArch: Introduce the numa_memblks conversion

Message ID 20250409070250.3225839-1-wangyuquan1236@phytium.com.cn
State New
Headers show
Series [1/1] LoongArch: Introduce the numa_memblks conversion | expand

Commit Message

Yuquan Wang April 9, 2025, 7:02 a.m. UTC
"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.

Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
---

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@phytium.com.cn/
[2]: https://lore.kernel.org/all/202503282026.QNaOAK79-lkp@intel.com/

 arch/loongarch/Kconfig            |  1 +
 arch/loongarch/include/asm/numa.h | 14 ----------
 arch/loongarch/kernel/numa.c      | 43 +------------------------------
 3 files changed, 2 insertions(+), 56 deletions(-)

Comments

Huacai Chen April 9, 2025, 2:20 p.m. UTC | #1
Hi, Yuquan,

On Wed, Apr 9, 2025 at 3:03 PM Yuquan Wang
<wangyuquan1236@phytium.com.cn> 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@phytium.com.cn>
> ---
>
> 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@phytium.com.cn/
> [2]: https://lore.kernel.org/all/202503282026.QNaOAK79-lkp@intel.com/
>
>  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
>
>
kernel test robot April 10, 2025, 11:29 p.m. UTC | #2
Hi Yuquan,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.15-rc1 next-20250410]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Yuquan-Wang/LoongArch-Introduce-the-numa_memblks-conversion/20250409-150524
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20250409070250.3225839-1-wangyuquan1236%40phytium.com.cn
patch subject: [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion
config: loongarch-randconfig-002-20250410 (https://download.01.org/0day-ci/archive/20250411/202504110627.AIvtEzM7-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250411/202504110627.AIvtEzM7-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504110627.AIvtEzM7-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> mm/numa_memblks.c:125:5: warning: no previous prototype for '__node_distance' [-Wmissing-prototypes]
     125 | int __node_distance(int from, int to)
         |     ^~~~~~~~~~~~~~~
--
   loongarch64-linux-ld: mm/numa_memblks.o: in function `numa_set_distance':
>> mm/numa_memblks.c:104: multiple definition of `numa_set_distance'; arch/loongarch/kernel/acpi.o:arch/loongarch/kernel/acpi.c:253: first defined here
>> loongarch64-linux-ld: mm/numa_memblks.o:mm/numa_memblks.c:13: multiple definition of `numa_nodes_parsed'; arch/loongarch/kernel/numa.o:arch/loongarch/kernel/numa.c:47: first defined here
diff mbox series

Patch

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;