Re: [PATCH v7 2/2] mm/memory_hotplug: optimize zone contiguous check when changing pfn range

From: Mike Rapoport

Date: Wed Aug 19 2026 - 10:58:14 EST


On Tue, Aug 18, 2026 at 04:57:02AM -0400, Yuan Liu wrote:
> When move_pfn_range_to_zone() or remove_pfn_range_from_zone() updates a
> zone, set_zone_contiguous() rescans the entire zone pageblock-by-pageblock
> to rebuild zone->contiguous. For large zones this is a significant cost
> during memory hotplug and hot-unplug.
>
> Add a new zone member, pages_with_online_memmap, that tracks the
> number of pages within the zone span that have an online memory map,
> including present pages and memory holes whose memory map has been
> initialized and for which pfn_to_online_page() succeeds.
>
> For early boot memory, pages_with_online_memmap is calculated in
> memmap_init_zone_range(). PFNs initialized by memmap_init_range() are
> included in pages_with_online_memmap, and hole PFNs for which
> pfn_to_online_page() succeeds are also counted in
> init_unavailable_range().

In what scenario it is possible that pfn_to_online_page() would fail at
that point?

--
Sincerely yours,
Mike.