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

From: David Hildenbrand (Arm)

Date: Thu Mar 26 2026 - 05:29:22 EST



> About AI feedback below
>
> init_unavailable_range() uses for_each_valid_pfn() and skips unmapped
> sections that lack a mem_map. If the full hole size is added anyway,
> pages_with_online_memmap could artificially match spanned_pages for
> zones with missing sections.
>
> Could this make zone_is_contiguous() incorrectly return true, bypassing
> pfn_valid() checks and potentially dereferencing missing sections?
> unsinged long zone_hole_pages
>
> I think if I can update the pages_with_online_memmap in the
> init_unavailable_range directly.

See how I handled it: I simply return the number of initialized pages
from the function. I think that should do.

--
Cheers,

David