[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aSxcs-jCnkrm8o0M@kernel.org>
Date: Sun, 30 Nov 2025 17:03:15 +0200
From: Mike Rapoport <rppt@...nel.org>
To: Swaraj Gaikwad <swarajgaikwad1925@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"open list:MEMBLOCK AND MEMORY MANAGEMENT INITIALIZATION" <linux-mm@...ck.org>,
open list <linux-kernel@...r.kernel.org>, skhan@...uxfoundation.org,
david.hunter.linux@...il.com
Subject: Re: [PATCH RFC] mm/memblock: Fix reserve_mem allocation overlapping
KHO scratch regions
Hi,
On Sun, Nov 30, 2025 at 05:29:39PM +0000, Swaraj Gaikwad wrote:
> Currently, `reserve_mem=` does not check for overlap with these KHO
> scratch areas. As a result, a memblock allocation may land inside a
> KHO-provided scratch region, leading to corruption or loss of the data.
> Noted by the following TODO:
> /* TODO: Allocation must be outside of scratch region */
> This RFC proposes extending `reserve_mem()` to allocate memory *only* in
> gaps outside the KHO scratch intervals. The logic is:
>
> 1. Walk through all KHO scratch ranges (kho_scratch[]).
> 2. Attempt allocation in each safe gap:
> [curr_start_addr, scratch_start)
> 3. If not found, attempt to allocate after the last scratch block.
> 4. If all attempts fail, return -ENOMEM.
>
> The allocation is done via `memblock_phys_alloc_range()`, which already
> supports constrained range allocation and preserves alignment guarantees.
>
> This is posted as an RFC because I would like feedback on:
>
> - Whether the allocation-gap scanning approach is acceptable.
> - Whether this logic belongs in reserve_mem() or should be abstracted
> into a helper for reuse.
> - I would appreciate guidance on testing this change.
So this is completely untested?
Kernel documentation asks for submitters to test their code:
https://docs.kernel.org/process/submit-checklist.html#test-your-code
Please study the code you are changing to understand how it should be
tested and don't submit untested patches.
> Signed-off-by: Swaraj Gaikwad <swarajgaikwad1925@...il.com>
--
Sincerely yours,
Mike.
Powered by blists - more mailing lists