Skip to content

Commit 6e49019

Browse files
xzpeterakpm00
authored andcommitted
mm/migrate: putback split folios when numa hint migration fails
This issue is not from any report yet, but by code observation only. This is yet another fix besides Hugh's patch [1] but on relevant code path, where eager split of folio can happen if the folio is already on deferred list during a folio migration. Here the issue is NUMA path (migrate_misplaced_folio()) may start to encounter such folio split now even with MR_NUMA_MISPLACED hint applied. Then when migrate_pages() didn't migrate all the folios, it's possible the split small folios be put onto the list instead of the original folio. Then putting back only the head page won't be enough. Fix it by putting back all the folios on the list. [1] https://lore.kernel.org/all/[email protected]/ [[email protected]: remove now unused local `nr_pages'] Link: https://lkml.kernel.org/r/[email protected] Fixes: 7262f20 ("mm/migrate: split source folio if it is on deferred split list") Signed-off-by: Peter Xu <[email protected]> Reviewed-by: Zi Yan <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Cc: Yang Shi <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Huang Ying <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 61c663e commit 6e49019

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

mm/migrate.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,20 +2621,13 @@ int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma,
26212621
int nr_remaining;
26222622
unsigned int nr_succeeded;
26232623
LIST_HEAD(migratepages);
2624-
int nr_pages = folio_nr_pages(folio);
26252624

26262625
list_add(&folio->lru, &migratepages);
26272626
nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_folio,
26282627
NULL, node, MIGRATE_ASYNC,
26292628
MR_NUMA_MISPLACED, &nr_succeeded);
2630-
if (nr_remaining) {
2631-
if (!list_empty(&migratepages)) {
2632-
list_del(&folio->lru);
2633-
node_stat_mod_folio(folio, NR_ISOLATED_ANON +
2634-
folio_is_file_lru(folio), -nr_pages);
2635-
folio_putback_lru(folio);
2636-
}
2637-
}
2629+
if (nr_remaining && !list_empty(&migratepages))
2630+
putback_movable_pages(&migratepages);
26382631
if (nr_succeeded) {
26392632
count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded);
26402633
if (!node_is_toptier(folio_nid(folio)) && node_is_toptier(node))

0 commit comments

Comments
 (0)