* [PATCH] mm/numa: fix uninitialized memory nodes causing kernel panic
@ 2025-08-15 10:30 Yin Tirui
2025-08-15 11:11 ` Kefeng Wang
0 siblings, 1 reply; 2+ messages in thread
From: Yin Tirui @ 2025-08-15 10:30 UTC (permalink / raw)
To: akpm, rppt, david, Jonathan.Cameron, dan.j.williams, linux-mm,
linux-kernel
Cc: yintirui, chenjun102, wangkefeng.wang
When the number of CPUs is fewer than the number of memory nodes,
some memory nodes may not be properly initialized because they are
not added to numa_nodes_parsed during memory parsing.
In of_numa_parse_memory_nodes(), after successfully adding a memory
block via numa_add_memblk(), the corresponding node ID should be
marked as parsed. However, the current implementation in numa_add_memblk()
only adds the memory block to numa_meminfo but fails to update
numa_nodes_parsed, leaving some nodes uninitialized.
During boot in a QEMU-emulated ARM64 NUMA environment, the kernel
panics when free_area_init() attempts to access NODE_DATA() for
memory nodes that were uninitialized.
[ 0.000000] Call trace:
[ 0.000000] free_area_init+0x620/0x106c (P)
[ 0.000000] bootmem_init+0x110/0x1dc
[ 0.000000] setup_arch+0x278/0x60c
[ 0.000000] start_kernel+0x70/0x748
[ 0.000000] __primary_switched+0x88/0x90
Cc: stable@vger.kernel.org
Fixes: 87482708210f ("mm: introduce numa_memblks")
Signed-off-by: Yin Tirui <yintirui@huawei.com>
---
mm/numa_memblks.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index 541a99c4071a..1dfe434e71b5 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -197,7 +197,13 @@ static void __init numa_move_tail_memblk(struct numa_meminfo *dst, int idx,
*/
int __init numa_add_memblk(int nid, u64 start, u64 end)
{
- return numa_add_memblk_to(nid, start, end, &numa_meminfo);
+ int ret;
+
+ ret = numa_add_memblk_to(nid, start, end, &numa_meminfo);
+ if (!ret)
+ node_set(nid, numa_nodes_parsed);
+
+ return ret;
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/numa: fix uninitialized memory nodes causing kernel panic
2025-08-15 10:30 [PATCH] mm/numa: fix uninitialized memory nodes causing kernel panic Yin Tirui
@ 2025-08-15 11:11 ` Kefeng Wang
0 siblings, 0 replies; 2+ messages in thread
From: Kefeng Wang @ 2025-08-15 11:11 UTC (permalink / raw)
To: Yin Tirui, akpm, rppt, david, Jonathan.Cameron, dan.j.williams,
linux-mm, linux-kernel
Cc: chenjun102
On 2025/8/15 18:30, Yin Tirui wrote:
> When the number of CPUs is fewer than the number of memory nodes,
> some memory nodes may not be properly initialized because they are
> not added to numa_nodes_parsed during memory parsing.
>
> In of_numa_parse_memory_nodes(), after successfully adding a memory
> block via numa_add_memblk(), the corresponding node ID should be
> marked as parsed. However, the current implementation in numa_add_memblk()
> only adds the memory block to numa_meminfo but fails to update
> numa_nodes_parsed, leaving some nodes uninitialized.
The issue is not existed in ACPI NUMA,
acpi_parse_memory_affinity
numa_add_memblk
node_set(node, numa_nodes_parsed);
so we only need to fix of_numa_parse_memory_nodes(),
>
> During boot in a QEMU-emulated ARM64 NUMA environment, the kernel
> panics when free_area_init() attempts to access NODE_DATA() for
> memory nodes that were uninitialized.
>
> [ 0.000000] Call trace:
> [ 0.000000] free_area_init+0x620/0x106c (P)
> [ 0.000000] bootmem_init+0x110/0x1dc
> [ 0.000000] setup_arch+0x278/0x60c
> [ 0.000000] start_kernel+0x70/0x748
> [ 0.000000] __primary_switched+0x88/0x90
>
> Cc: stable@vger.kernel.org
> Fixes: 87482708210f ("mm: introduce numa_memblks")
I think the Fixes tag should be commit 767507654c22
("arch_numa: switch over to numa_memblks").
> Signed-off-by: Yin Tirui <yintirui@huawei.com>
> ---
> mm/numa_memblks.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
> index 541a99c4071a..1dfe434e71b5 100644
> --- a/mm/numa_memblks.c
> +++ b/mm/numa_memblks.c
> @@ -197,7 +197,13 @@ static void __init numa_move_tail_memblk(struct numa_meminfo *dst, int idx,
> */
> int __init numa_add_memblk(int nid, u64 start, u64 end)
> {
> - return numa_add_memblk_to(nid, start, end, &numa_meminfo);
> + int ret;
> +
> + ret = numa_add_memblk_to(nid, start, end, &numa_meminfo);
> + if (!ret)
> + node_set(nid, numa_nodes_parsed);
> +
> + return ret;
> }
>
> /**
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-15 11:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15 10:30 [PATCH] mm/numa: fix uninitialized memory nodes causing kernel panic Yin Tirui
2025-08-15 11:11 ` Kefeng Wang
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).