[PATCH 06/60] mm/memory_hotplug: migrate offlined pages to common memory

From: Gregory Price via B4 Relay

Date: Fri Nov 20 2026 - 13:11:02 EST


From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>

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.

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 e5cb770e4b09..1d3d1792074c 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1926,7 +1926,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,
@@ -1941,9 +1941,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.56.1