aboutsummaryrefslogtreecommitdiffstats
path: root/mm/migrate_device.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2022-09-26 13:13:15 -0700
committerAndrew Morton <akpm@linux-foundation.org>2022-09-26 13:13:15 -0700
commit6d751329e761338faa9c24c2c9736f27bc54282b (patch)
tree6e1778a7448552c58d12da88f70f6ad2718d55da /mm/migrate_device.c
parent088b8aa537c2c767765f1c19b555f21ffe555786 (diff)
parent59298997df89e19aad426d4ae0a7e5037074da5a (diff)
downloadlinux-6d751329e761338faa9c24c2c9736f27bc54282b.tar.gz
Merge branch 'mm-hotfixes-stable' into mm-stable
Diffstat (limited to 'mm/migrate_device.c')
-rw-r--r--mm/migrate_device.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 72354248dde9a..d8efd5a0eb405 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -7,6 +7,7 @@
#include <linux/export.h>
#include <linux/memremap.h>
#include <linux/migrate.h>
+#include <linux/mm.h>
#include <linux/mm_inline.h>
#include <linux/mmu_notifier.h>
#include <linux/oom.h>
@@ -200,10 +201,10 @@ again:
bool anon_exclusive;
pte_t swp_pte;
+ flush_cache_page(vma, addr, pte_pfn(*ptep));
anon_exclusive = PageAnon(page) && PageAnonExclusive(page);
if (anon_exclusive) {
- flush_cache_page(vma, addr, pte_pfn(*ptep));
- ptep_clear_flush(vma, addr, ptep);
+ pte = ptep_clear_flush(vma, addr, ptep);
if (page_try_share_anon_rmap(page)) {
set_pte_at(mm, addr, ptep, pte);
@@ -213,11 +214,15 @@ again:
goto next;
}
} else {
- ptep_get_and_clear(mm, addr, ptep);
+ pte = ptep_get_and_clear(mm, addr, ptep);
}
migrate->cpages++;
+ /* Set the dirty flag on the folio now the pte is gone. */
+ if (pte_dirty(pte))
+ folio_mark_dirty(page_folio(page));
+
/* Setup special migration page table entry */
if (mpfn & MIGRATE_PFN_WRITE)
entry = make_writable_migration_entry(
@@ -261,13 +266,14 @@ next:
migrate->dst[migrate->npages] = 0;
migrate->src[migrate->npages++] = mpfn;
}
- arch_leave_lazy_mmu_mode();
- pte_unmap_unlock(ptep - 1, ptl);
/* Only flush the TLB if we actually modified any entries */
if (unmapped)
flush_tlb_range(walk->vma, start, end);
+ arch_leave_lazy_mmu_mode();
+ pte_unmap_unlock(ptep - 1, ptl);
+
return 0;
}