Re: [PATCH v7 2/2] mm/memory hotplug/unplug: Optimize zone->contiguous update when changes pfn range

From: David Hildenbrand (Red Hat)

Date: Tue Jan 06 2026 - 15:25:52 EST



One more thing, the fact that the clear_zone_contiguous() happens in move_pfn_range_to_zone() is a bit suboptimal.

Maybe we need a comment here like

/*
* Calculate the new zone contig state before move_pfn_range_to_zone()
* sets the zone temporarily to non-contiguous.
*/

Or something like that.

Alternatively, we have to rework the code a bit that this dependency is a bit clearer.

+ new_contiguous_state = zone_contig_state_after_growing(zone, pfn, nr_pages);
/* associate pfn range with the zone */
move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_MOVABLE,
@@ -1204,7 +1273,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages,
}
online_pages_range(pfn, nr_pages);
- set_zone_contiguous(zone);
+ set_zone_contiguous(zone, new_contiguous_state);
adjust_present_page_count(pfn_to_page(pfn), group, nr_pages);

--
Cheers

David