* [PATCH] memblock: fix crash when reserved memory is not added to memory
@ 2024-01-18 6:18 Yajun Deng
2024-01-18 6:42 ` Mike Rapoport
0 siblings, 1 reply; 3+ messages in thread
From: Yajun Deng @ 2024-01-18 6:18 UTC (permalink / raw)
To: rppt, akpm; +Cc: linux-mm, linux-kernel, Yajun Deng
After commit 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()"),
we set nid on all reserved pages based on memory region, but some reserved
memory may not be added to memory on certain architectures. The nid is
invalid.
Add the nid check, make sure the nid is valid by early_pfn_to_nid().
Fixes: 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()")
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
mm/memblock.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/memblock.c b/mm/memblock.c
index abd92869874d..4dcb2ee35eca 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2176,6 +2176,9 @@ static void __init memmap_init_reserved_pages(void)
start = region->base;
end = start + region->size;
+ if (nid == NUMA_NO_NODE || nid >= MAX_NUMNODES)
+ nid = early_pfn_to_nid(PFN_DOWN(start));
+
reserve_bootmem_region(start, end, nid);
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] memblock: fix crash when reserved memory is not added to memory
2024-01-18 6:18 [PATCH] memblock: fix crash when reserved memory is not added to memory Yajun Deng
@ 2024-01-18 6:42 ` Mike Rapoport
2024-01-19 2:26 ` Huang Pei
0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2024-01-18 6:42 UTC (permalink / raw)
To: Yajun Deng, Huang Pei; +Cc: akpm, linux-mm, linux-kernel
(adding Huang Pei to verify this fixes the crash on loongarch)
On Thu, Jan 18, 2024 at 02:18:53PM +0800, Yajun Deng wrote:
> After commit 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()"),
> we set nid on all reserved pages based on memory region, but some reserved
> memory may not be added to memory on certain architectures. The nid is
> invalid.
>
> Add the nid check, make sure the nid is valid by early_pfn_to_nid().
>
> Fixes: 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()")
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
> mm/memblock.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index abd92869874d..4dcb2ee35eca 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2176,6 +2176,9 @@ static void __init memmap_init_reserved_pages(void)
> start = region->base;
> end = start + region->size;
>
> + if (nid == NUMA_NO_NODE || nid >= MAX_NUMNODES)
> + nid = early_pfn_to_nid(PFN_DOWN(start));
> +
> reserve_bootmem_region(start, end, nid);
> }
> }
> --
> 2.25.1
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memblock: fix crash when reserved memory is not added to memory
2024-01-18 6:42 ` Mike Rapoport
@ 2024-01-19 2:26 ` Huang Pei
0 siblings, 0 replies; 3+ messages in thread
From: Huang Pei @ 2024-01-19 2:26 UTC (permalink / raw)
To: Mike Rapoport; +Cc: Yajun Deng, akpm, linux-mm, linux-kernel
On Thu, Jan 18, 2024 at 08:42:08AM +0200, Mike Rapoport wrote:
> (adding Huang Pei to verify this fixes the crash on loongarch)
>
It fixed 61167ad5fecd on MIPS/loongson64, tested on 3b1500 with only
this one;
My loongarch64 machine is not available now, I can not test it, sorry.
It is already applied a arch-specific workaround in v6.5+
> On Thu, Jan 18, 2024 at 02:18:53PM +0800, Yajun Deng wrote:
> > After commit 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()"),
> > we set nid on all reserved pages based on memory region, but some reserved
> > memory may not be added to memory on certain architectures. The nid is
> > invalid.
> >
> > Add the nid check, make sure the nid is valid by early_pfn_to_nid().
> >
> > Fixes: 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()")
> > Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> > ---
> > mm/memblock.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/mm/memblock.c b/mm/memblock.c
> > index abd92869874d..4dcb2ee35eca 100644
> > --- a/mm/memblock.c
> > +++ b/mm/memblock.c
> > @@ -2176,6 +2176,9 @@ static void __init memmap_init_reserved_pages(void)
> > start = region->base;
> > end = start + region->size;
> >
> > + if (nid == NUMA_NO_NODE || nid >= MAX_NUMNODES)
> > + nid = early_pfn_to_nid(PFN_DOWN(start));
> > +
> > reserve_bootmem_region(start, end, nid);
> > }
> > }
> > --
> > 2.25.1
> >
>
> --
> Sincerely yours,
> Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-23 7:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18 6:18 [PATCH] memblock: fix crash when reserved memory is not added to memory Yajun Deng
2024-01-18 6:42 ` Mike Rapoport
2024-01-19 2:26 ` Huang Pei
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).