Re: [PATCH v7 2/2] mm/memory hotplug/unplug: Optimize zone->contiguous update when changes pfn range
From: Li, Tianyou
Date: Thu Jan 08 2026 - 10:41:56 EST
On 1/7/2026 4:25 AM, David Hildenbrand (Red Hat) wrote:
Will change accordingly. Thanks.
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.
Agreed, probably we can have this optimization first then explore a more explicit approach for the zone contiguous state management.
+ 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);
Regards,
Tianyou