Re: [PATCH v3] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range

Wei Yang
2026-04-16T02:23:59Z

On Tue, Apr 07, 2026 at 11:16:15PM -0400, Yuan Liu wrote:
[...]
>
> /*
>@@ -956,9 +957,22 @@ static void __init memmap_init_zone_range(struct zone *zone,
> memmap_init_range(end_pfn - start_pfn, nid, zone_id, start_pfn,
> zone_end_pfn, MEMINIT_EARLY, NULL, MIGRATE_MOVABLE,
> false);
>+ zone->pages_with_online_memmap += end_pfn - start_pfn;
>
>- if (*hole_pfn < start_pfn)
>- init_unavailable_range(*hole_pfn, start_pfn, zone_id, nid);
>+ if (*hole_pfn < start_pfn) {
>+ unsigned long pgcnt;
>+
>+ if (*hole_pfn < zone_start_pfn) {
>+ init_unavailable_range(*hole_pfn, zone_start_pfn,
>+ zone_id, nid);

One question here:

init_unavailable_range(zone_id)
__init_single_page(zone_id)
set_page_links(zone_id)
set_page_zone(page, zone_id)

[hole_pfn, zone_start_pfn) doesn't belong to this zone. Would this be
a problem?

But it seems we have already done this for a long time.

>+ pgcnt = init_unavailable_range(zone_start_pfn,
>+ start_pfn, zone_id, nid);
>+ } else {
>+ pgcnt = init_unavailable_range(*hole_pfn, start_pfn,
>+ zone_id, nid);
>+ }
>+ zone->pages_with_online_memmap += pgcnt;
>+ }
>
> *hole_pfn = end_pfn;
> }

--
Wei Yang
Help you, Help me