diff mbox series

[2/2] mm/migrate: preserve soft dirty in remove_migration_pte()

Message ID 20200831212222.22409-3-rcampbell@nvidia.com (mailing list archive)
State New, archived
Headers show
Series mm/migrate: preserve soft dirty in remove_migration_pte() | expand

Commit Message

Ralph Campbell Aug. 31, 2020, 9:22 p.m. UTC
The code to remove a migration PTE and replace it with a device private
PTE was not copying the soft dirty bit from the migration entry.
This could lead to page contents not being marked dirty when faulting
the page back from device private memory.

Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
---
 mm/migrate.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Christoph Hellwig Sept. 1, 2020, 5:20 a.m. UTC | #1
On Mon, Aug 31, 2020 at 02:22:22PM -0700, Ralph Campbell wrote:
> The code to remove a migration PTE and replace it with a device private
> PTE was not copying the soft dirty bit from the migration entry.
> This could lead to page contents not being marked dirty when faulting
> the page back from device private memory.
> 
> Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index fe339a847328..4f89360d9e77 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -249,6 +249,8 @@  static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
 		if (unlikely(is_device_private_page(new))) {
 			entry = make_device_private_entry(new, pte_write(pte));
 			pte = swp_entry_to_pte(entry);
+			if (pte_swp_soft_dirty(*pvmw.pte))
+				pte = pte_swp_mksoft_dirty(pte);
 			if (pte_swp_uffd_wp(*pvmw.pte))
 				pte = pte_swp_mkuffd_wp(pte);
 		}