Re: [PATCH 2/2] memblock: don't release high memory to page allocator when HIGHMEM is off

From: Nathan Chancellor
Date: Wed Mar 26 2025 - 11:26:44 EST


On Tue, Mar 25, 2025 at 01:49:28PM +0200, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx>
>
> Nathan Chancellor reports the following crash on a MIPS system with
> CONFIG_HIGHMEM=n:
...
> The crash happens because commit 6faea3422e3b ("arch, mm: streamline
> HIGHMEM freeing") too eagerly frees high memory to the page allocator even
> when HIGHMEM is disabled.
>
> Make sure that when CONFIG_HIGHMEM=n the high memory is not released to the
> page allocator.
>
> Link: https://lore.kernel.org/all/20250323190647.GA1009914@ax162
> Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Fixes: 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>

> ---
> mm/memblock.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 64ae678cd1d1..d7ff8dfe5f88 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2166,6 +2166,9 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
> unsigned long start_pfn = PFN_UP(start);
> unsigned long end_pfn = PFN_DOWN(end);
>
> + if (!IS_ENABLED(CONFIG_HIGHMEM) && end_pfn > max_low_pfn)
> + end_pfn = max_low_pfn;
> +
> if (start_pfn >= end_pfn)
> return 0;
>
> --
> 2.47.2
>