From: Mike Rapoport <rppt@kernel.org>
To: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"open list:MEMBLOCK AND MEMORY MANAGEMENT INITIALIZATION"
<linux-mm@kvack.org>, open list <linux-kernel@vger.kernel.org>,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com
Subject: Re: [PATCH RFC] mm/memblock: Fix reserve_mem allocation overlapping KHO scratch regions
Date: Sun, 30 Nov 2025 17:03:15 +0200 [thread overview]
Message-ID: <aSxcs-jCnkrm8o0M@kernel.org> (raw)
In-Reply-To: <20251130172939.574999-1-swarajgaikwad1925@gmail.com>
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@gmail.com>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2025-11-30 15:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-30 17:29 [PATCH RFC] mm/memblock: Fix reserve_mem allocation overlapping KHO scratch regions Swaraj Gaikwad
2025-11-30 15:03 ` Mike Rapoport [this message]
2025-11-30 21:15 ` Swaraj Gaikwad
2025-12-01 6:50 ` Mike Rapoport
2025-12-01 19:07 ` kernel test robot
2025-12-01 20:31 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aSxcs-jCnkrm8o0M@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david.hunter.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=skhan@linuxfoundation.org \
--cc=swarajgaikwad1925@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.