* [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion
@ 2025-04-09 7:02 Yuquan Wang
2025-04-09 14:20 ` Huacai Chen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yuquan Wang @ 2025-04-09 7:02 UTC (permalink / raw)
To: chenhuacai, kernel, jiaxun.yang, rppt, akpm, david,
Jonathan.Cameron, dave.hansen, dan.j.williams, alison.schofield
Cc: chenbaozi, loongarch, linux-kernel, linux-acpi, linux-cxl,
Yuquan Wang
"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(-)
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion
2025-04-09 7:02 [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion Yuquan Wang
@ 2025-04-09 14:20 ` Huacai Chen
2025-04-10 23:29 ` kernel test robot
2025-04-19 7:51 ` Mike Rapoport
2 siblings, 0 replies; 4+ messages in thread
From: Huacai Chen @ 2025-04-09 14:20 UTC (permalink / raw)
To: Yuquan Wang
Cc: kernel, jiaxun.yang, rppt, akpm, david, Jonathan.Cameron,
dave.hansen, dan.j.williams, alison.schofield, chenbaozi,
loongarch, linux-kernel, linux-acpi, linux-cxl
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
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion
2025-04-09 7:02 [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion Yuquan Wang
2025-04-09 14:20 ` Huacai Chen
@ 2025-04-10 23:29 ` kernel test robot
2025-04-19 7:51 ` Mike Rapoport
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-04-10 23:29 UTC (permalink / raw)
To: Yuquan Wang, chenhuacai, kernel, jiaxun.yang, rppt, akpm, david,
Jonathan.Cameron, dave.hansen, dan.j.williams, alison.schofield
Cc: oe-kbuild-all, chenbaozi, loongarch, linux-kernel, linux-acpi,
linux-cxl, Yuquan Wang
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
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion
2025-04-09 7:02 [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion Yuquan Wang
2025-04-09 14:20 ` Huacai Chen
2025-04-10 23:29 ` kernel test robot
@ 2025-04-19 7:51 ` Mike Rapoport
2 siblings, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2025-04-19 7:51 UTC (permalink / raw)
To: Yuquan Wang
Cc: chenhuacai, kernel, jiaxun.yang, akpm, david, Jonathan.Cameron,
dave.hansen, dan.j.williams, alison.schofield, chenbaozi,
loongarch, linux-kernel, linux-acpi, linux-cxl
Hi Yuquan,
On Wed, Apr 09, 2025 at 03:02:50PM +0800, Yuquan Wang 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.
>
> 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.
I think you can just add a dummy static inline numa_add_reserved_memblk()
to arch/loongarch/include/asm/numa.h to fix the build. Then moving
loongarch to numa_memblks won't be a stopper for your change.
> 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/
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-19 7:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-09 7:02 [PATCH 1/1] LoongArch: Introduce the numa_memblks conversion Yuquan Wang
2025-04-09 14:20 ` Huacai Chen
2025-04-10 23:29 ` kernel test robot
2025-04-19 7:51 ` Mike Rapoport
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).