[PATCH] mm: migrate: restore the nmask after successfully allocating on the target node
From: wangchuanguo
Date: Tue Mar 25 2025 - 23:13:58 EST
If memory is successfully allocated on the target node and the
function directly returns without value restore for nmask,
non-first migration operations in migrate_pages() by again label
may ignore the nmask settings, thereby allowing new memory
allocations for migration on any node.
Signed-off-by: wangchuanguo <wangchuanguo@xxxxxxxxxx>
---
mm/vmscan.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index b620d74b0f66..9467b2acef28 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1026,8 +1026,10 @@ struct folio *alloc_migrate_folio(struct folio *src, unsigned long private)
mtc->nmask = NULL;
mtc->gfp_mask |= __GFP_THISNODE;
dst = alloc_migration_target(src, (unsigned long)mtc);
- if (dst)
+ if (dst) {
+ mtc->nmask = allowed_mask;
return dst;
+ }
mtc->gfp_mask &= ~__GFP_THISNODE;
mtc->nmask = allowed_mask;
--
2.39.3