[PATCH 09/12] memblock: introduce MEMBLOCK_KHO_SCRATCH_EXT

Pratyush Yadav pratyush at kernel.org
Mon May 11 09:46:31 PDT 2026


On Mon, May 11 2026, Mike Rapoport wrote:

> On Wed, Apr 29, 2026 at 03:39:11PM +0200, Pratyush Yadav wrote:
>> From: "Pratyush Yadav (Google)" <pratyush at kernel.org>
>> 
>> In the upcoming commits, the KHO will learn how to discover free blocks
>> of memory by walking the KHO radix tree. It will then mark those regions
>> as scratch to allow memory allocation in case scratch runs low.
>> 
>> To differentiate the extended scratch areas from the main scratch areas,
>> introduce MEMBLOCK_KHO_SCRATCH_EXT. Use it when choosing memblock flags
>> for allocations during scratch-only. Teach should_skip_region() to check
>> for both flags before deciding if the region should be skipped.
>
> Why there's a need to differentiate SCRATCH and SCRATCH_EXT?
> SCRATCH (I still hate the name) means "memory memblock can safely use for
> the allocations". Initially this memory comes from the reservations in the
> first kernel, but if the second kernel can find more memory to extend it,
> why that additional memory should be treated differently? 

Two reasons:

1. We mark SCRATCH as MIGRATE_CMA. We don't want to do that for
   SCRATCH_EXT since this memory can be used for non-movable
   allocations.

2. Gigantic (1G) huge pages can not be allocated from scratch. They can
   be preserved memory and thus should not be allocated from SCRATCH.
   See patch 12 that does allocations for gigantic huge pages only from
   SCRATCH_EXT.

I will add this in the commit message for the next version.

Naming is hard, so if you have any better names I'm all ears :-)

>
>> Signed-off-by: Pratyush Yadav (Google) <pratyush at kernel.org>
>> ---
>> 
>> Notes:
>>     Checkpatch complains about no space after MEMBLOCK_KHO_SCRATCH_EXT in
>>     the declaration, but doing so makes it nicely align with all the other
>>     numbers. Mike, if you'd like I can add some whitespace.
>> 
>>  include/linux/memblock.h | 10 ++++++++++
>>  mm/memblock.c            | 41 ++++++++++++++++++++++++++++++++++------
>>  2 files changed, 45 insertions(+), 6 deletions(-)

-- 
Regards,
Pratyush Yadav



More information about the kexec mailing list