[PATCH 07/22] mm/memory_hotplug: migrate offlined pages to common memory
From: Gregory Price (Meta)
Date: Sat Nov 14 2026 - 02:11:08 EST
do_migrate_range() / alloc_migration_target() is only capable of
allocating memory on N_MEMORY_COMMON nodes. The destination nodemask
presently starts with N_MEMORY and removes the source-node.
In the current code, if the destination mask becomes empty, the source
node is restored to allow migration during partial offlining.
Consider this configuration:
Node0 = N_MEMORY_COMMON
Node1 = N_MEMORY, not N_MEMORY_COMMON
Node 1 keeps the destination mask non-empty, despite being unreachable.
This leaves migration with no usable destination because the source
node is not an eligible allocation target.
Restrict the hot-unplug migration target-list to N_MEMORY_COMMON so it
reflects the nodes the allocator can reach.
All memory is common at this point - behavior is unchanged.
Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
---
mm/memory_hotplug.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 490f400498f14..29ff2c46499b3 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1904,7 +1904,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
folio_put(folio);
}
if (!list_empty(&source)) {
- nodemask_t nmask = node_states[N_MEMORY];
+ nodemask_t nmask = node_states[N_MEMORY_COMMON];
struct migration_target_control mtc = {
.nmask = &nmask,
.gfp_mask = GFP_KERNEL | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
@@ -1919,9 +1919,9 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
mtc.nid = folio_nid(list_first_entry(&source, struct folio, lru));
/*
- * try to allocate from a different node but reuse this node
- * if there are no other online nodes to be used (e.g. we are
- * offlining a part of the only existing node)
+ * try to allocate from a different common node but reuse this
+ * node if there are no other common nodes to be used (e.g. we
+ * are offlining a part of the only common node)
*/
node_clear(mtc.nid, nmask);
if (nodes_empty(nmask))
--
2.53.1-Meta