mm: migrate: restore the nmask after successfully allocating on the target node
Quoted 10 lines · wangchuanguo
Quoted 5 lines
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.I have no opinion on whether this is the right thing to do or not, but if it is
I don't think so. When memory allocation fails on the target node, there is already a recovery operation for the nmask value below. Therefore, the nmask value should only be restored when memory allocation is successfully completed on the target node.
Quoted 24 lines
Review struct folio *alloc_migrate_folio(struct folio *src,
Quoted 2 lines
+++
b/mm/vmscan.c(quoted diff) +0
-0@@ -1026,8 +1026,10 @@ struct folio *alloc_migrate_folio(struct folio *src,unsigned long private)
Review struct folio *alloc_migrate_folio(struct folio *src, · line 1035
Quoted 11 lines
(quoted diff) +3
-1mtc->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;this should be:
dst = alloc_migration_target(src, (unsigned long)mtc);(quoted diff) +1
-0+ mtc->nmask = allowed_mask;if (dst) return dst; mtc->gfp_mask &= ~__GFP_THISNODE;(quoted diff) +0
-1- mtc->nmask = allowed_mask;
Quoted 8 lines · Simon Wang (王传国)
Quoted 8 lines · wangchuanguo
Quoted 5 lines
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.
Quoted 4 lines
Quoted 2 lines
I have no opinion on whether this is the right thing to do or not, but if it is
I don't think so. When memory allocation fails on the target node, there is already a recovery operation for the nmask value below. Therefore, the nmask value should only be restored when memory allocation is successfully completed on the target node.
But that is not what the code is doing, is it? With the changes applied I mean. You are restoring mtc->nmask in case you managed to allocate for __GFP_THISNODE and after you clear the flag, so we might as well do it just once at the beginning after calling alloc_migration_target for the first time.
Signature · 2 lines
Oscar Salvador SUSE Labs