[PATCH 3/4] userfaultfd: mark THPs moved by UFFDIO_MOVE soft-dirty
From: Mike Rapoport (Microsoft)
Date: Wed Dec 02 2026 - 13:20:21 EST
UFFDIO_MOVE marks moved PTEs and a moved huge zero page soft-dirty, like
mremap() does.
A THP is the exception. move_pages_huge_pmd() creates the destination PMD
from scratch and does not mark it soft-dirty, so soft-dirty trackers such
as CRIU miss the move.
Mark the moved THP PMD soft-dirty with move_soft_dirty_pmd(), like
mremap() does for PMDs.
Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
---
mm/huge_memory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index d065b26a94dfa..f0cb8b0e469f4 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3014,6 +3014,7 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
_dst_pmd = folio_mk_pmd(src_folio, dst_vma->vm_page_prot);
/* Follow mremap() behavior and treat the entry dirty after the move */
_dst_pmd = pmd_mkwrite(pmd_mkdirty(_dst_pmd), dst_vma);
+ _dst_pmd = move_soft_dirty_pmd(_dst_pmd);
} else {
src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd);
_dst_pmd = move_soft_dirty_pmd(src_pmdval);
--
2.53.0