Skip to content

Conversation

@yliu80
Copy link
Collaborator

@yliu80 yliu80 commented Dec 8, 2025

when new memory is plugged, set_zone_contiguous will never set the zone as contiguous, because the memory section of the newly plugged memory is still offline during the zone contiguity check.

if the memory section of the pfn is offline, __pageblock_pfn_to_page cannot return a page for that pfn, causing set_zone_contiguous to skip setting zone->contiguous.

The fix is to move set_zone_contiguous after online_mem_sections, ensuring that the newly plugged memory is already onlined before the set_zone_contiguous.

Reviewed-by: Tianyou Li tianyou.li@intel.com
Reviewed-by: Nanhai Zou nanhai.zou@intel.com
Signed-off-by: Liu, Yuan1 yuan1.liu@intel.com

@TianyouLi
Copy link
Owner

mm/memory hotplug: Fix zone->contiguous always false when hotplug

Function set_zone_contiguous used __pageblock_pfn_to_page to check the whole pageblock is in the same zone. One assumption is the memory section must online, otherwise the __pageblock_pfn_to_page will return NULL, then the set_zone_contiguous will be false. When move_pfn_range_to_zone invoked set_zone_contiguous, since the memory section did not online, the return value will always be false.

To fix this issue, we removed the set_zone_contiguous from the move_pfn_range_to_zone, and place it after memory section onlined.

Function remove_pfn_range_from_zone did not have this issue because memory section remains online at the time set_zone_contiguous invoked.

@TianyouLi
Copy link
Owner

This series contains 2 patches, the first one add a fast path to check the zone->contiguous, the second one fix an issue when check the zone->contiguous at the slow path during zone grows.

@TianyouLi
Copy link
Owner

This series contains 2 patches, the first one add a fast path to check the zone->contiguous, the second one fix an issue when check the zone->contiguous at the slow path during zone grows. The issue fixed by the second patch can be found in the original code path without the first patch.

Function set_zone_contiguous used __pageblock_pfn_to_page to
check the whole pageblock is in the same zone. One assumption is
the memory section must online, otherwise the __pageblock_pfn_to_page
will return NULL, then the set_zone_contiguous will be false.
When move_pfn_range_to_zone invoked set_zone_contiguous, since the
memory section did not online, the return value will always be false.

To fix this issue, we removed the set_zone_contiguous from the
move_pfn_range_to_zone, and place it after memory section onlined.

Function remove_pfn_range_from_zone did not have this issue because
memory section remains online at the time set_zone_contiguous invoked.

Reviewed-by: Tianyou Li <tianyou.li@intel.com>
Reviewed-by: Nanhai Zou <nanhai.zou@intel.com>
Signed-off-by: Liu, Yuan1 <yuan1.liu@intel.com>
@TianyouLi TianyouLi merged commit c92e2d8 into mm-hotplug-opt-simplified Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants