[PATCH 35/60] mm/mempolicy: keep private nodes out of migrate_pages() destinations

From: Gregory Price via B4 Relay

Date: Fri Nov 20 2026 - 13:21:57 EST


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

migrate_pages(2) intersects its destination nodes with the caller's
cpuset, which can include private nodes.

A private destination gets mapped to some source node, and every page
bound for it attempts a __GFP_THISNODE allocation. A private node is not
on its own __GFP_THISNODE zonelist, so the call fails with -ENOMEM and
logs an allocation failure.

Leave private nodes out of the destination mask, as move_pages(2)
already rejects them. A mask that names only private nodes fails with
-EINVAL.

Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
---
mm/mempolicy.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 81ccc481cea1..2bfe8b2b6287 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1958,6 +1958,8 @@ static int kernel_migrate_pages(pid_t pid, unsigned long maxnode,
}

task_nodes = cpuset_mems_allowed(current);
+ /* Private memory is not a migration destination. */
+ nodes_andnot(task_nodes, task_nodes, node_states[N_MEMORY_PRIVATE]);
if (!nodes_and(*new, *new, task_nodes))
goto out_put;


--
2.56.1