Fix splitting a folio in PMD collection to collect a skip on folio split failure and continue the loop at the current position on success. This fixes an issue where migration entries that had already been collected could accidentally be left behind. Cc: Andrew Morton Cc: David Hildenbrand Cc: Zi Yan Cc: Joshua Hahn Cc: Rakie Kim Cc: Byungchul Park Cc: Gregory Price Cc: Ying Huang Cc: Alistair Popple Cc: Oscar Salvador Cc: Lorenzo Stoakes Cc: Baolin Wang Cc: "Liam R. Howlett" Cc: Nico Pache Cc: Ryan Roberts Cc: Dev Jain Cc: Barry Song Cc: Lyude Paul Cc: Danilo Krummrich Cc: David Airlie Cc: Simona Vetter Cc: Ralph Campbell Cc: Mika Penttilä Cc: Francois Dugast Cc: Balbir Singh Signed-off-by: Matthew Brost --- This fixup should be squashed into the patch "mm/migrate_device: add THP splitting during migration" in mm/mm-unstable --- mm/migrate_device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 4506e96dcd20..ab373fd38961 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -313,16 +313,18 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, if (folio_test_large(folio)) { int ret; + arch_leave_lazy_mmu_mode(); pte_unmap_unlock(ptep, ptl); ret = migrate_vma_split_folio(folio, migrate->fault_page); if (ret) { - ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); - goto next; + if (unmapped) + flush_tlb_range(walk->vma, start, end); + + return migrate_vma_collect_skip(addr, end, walk); } - addr = start; goto again; } -- 2.34.1