Skip to content

Commit b360edb

Browse files
rientjestorvalds
authored andcommitted
mm, mempolicy: migrate_to_node should only migrate to node
migrate_to_node() is intended to migrate a page from one source node to a target node. Today, migrate_to_node() could end up migrating to any node, not only the target node. This is because the page migration allocator, new_node_page() does not pass __GFP_THISNODE to alloc_pages_exact_node(). This causes the target node to be preferred but allows fallback to any other node in order of affinity. Prevent this by allocating with __GFP_THISNODE. If memory is not available, -ENOMEM will be returned as appropriate. Signed-off-by: David Rientjes <[email protected]> Reviewed-by: Naoya Horiguchi <[email protected]> Cc: Mel Gorman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3cb29d1 commit b360edb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/mempolicy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,8 @@ static struct page *new_node_page(struct page *page, unsigned long node, int **x
945945
return alloc_huge_page_node(page_hstate(compound_head(page)),
946946
node);
947947
else
948-
return alloc_pages_exact_node(node, GFP_HIGHUSER_MOVABLE, 0);
948+
return alloc_pages_exact_node(node, GFP_HIGHUSER_MOVABLE |
949+
__GFP_THISNODE, 0);
949950
}
950951

951952
/*

0 commit comments

Comments
 (0)