Re: [PATCH v2 5/7] mm/page_ext: allocate page extensions early for SPARSEMEM

From: Chris Down

Date: Wed Nov 18 2026 - 02:00:29 EST


Hi Muchun,

Muchun Song writes:
Mike's suggestion considerably simplifies the code, and early page_ext is
only needed by optional debugging and instrumentation users. I would prefer
to keep this approach.

You're probably right. But can I cheekily suggest something in the middle
perhaps? :-)

Given the zones are already set up before page_ext_alloc() runs, perhaps
you can pass the start of the node's ZONE_MOVABLE as max_addr to
memblock_alloc_try_nid() when the node has one. The general idea is:

struct zone *movable = &NODE_DATA(nid)->node_zones[ZONE_MOVABLE];
phys_addr_t max_addr = MEMBLOCK_ALLOC_ACCESSIBLE;

if (!zone_is_empty(movable))
max_addr = PFN_PHYS(movable->zone_start_pfn);
addr = memblock_alloc_try_nid(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS),
max_addr, nid);
if (!addr && max_addr != MEMBLOCK_ALLOC_ACCESSIBLE)
addr = memblock_alloc_try_nid(size, PAGE_SIZE,
__pa(MAX_DMA_ADDRESS),
MEMBLOCK_ALLOC_ACCESSIBLE, nid);

I briefly tried that and it seems to work quite nicely.

But I don't object to it even without that, so feel free to add either way:

Reviewed-by: Chris Down <chris@xxxxxxxxxxxxxx>

Thanks!

Chris