mm/migrate: preserve soft dirty in remove_migration_pte()
Subsystems (2)
cover mm/migrate: preserve soft dirty in remove_migration_pte()
Two small patches for Andrew Morton's mm tree.
I happened to notice this from code inspection after seeing Alistair Popple's patch ("mm/rmap: Fixup copying of soft dirty and uffd ptes").
Ralph Campbell (2):
mm/migrate: remove unnecessary is_zone_device_page() check mm/migrate: preserve soft dirty in remove_migration_pte()
mm/migrate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 mm/migrate: remove unnecessary is_zone_device_page() check
The check for is_zone_device_page() and is_device_private_page() is unnecessary since the latter is sufficient to determine if the page is a device private page. Simplify the code for easier reading.
--- mm/migrate.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
mm/migrate.c +5 -7
@@ -246,13 +246,11 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,else if (pte_swp_uffd_wp (*pvmw.pte)) pte =pte_mkuffd_wp (pte); -if (unlikely (is_zone_device_page (new))) { -if (is_device_private_page (new)) { - entry =make_device_private_entry (new,pte_write (pte)); - pte =swp_entry_to_pte (entry); -if (pte_swp_uffd_wp (*pvmw.pte)) - pte =pte_swp_mkuffd_wp (pte); - } +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_uffd_wp (*pvmw.pte)) + pte =pte_swp_mkuffd_wp (pte); }#ifdef CONFIG_HUGETLB_PAGE
Signature · 1 line
2.20.1
Re: [PATCH 1/2] mm/migrate: remove unnecessary is_zone_device_page() check
Looks good:
PATCH 2/2 mm/migrate: preserve soft dirty in remove_migration_pte()
In reply to Ralph CampbellThe 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.
--- mm/migrate.c | 2 ++ 1 file changed, 2 insertions(+)
mm/migrate.c +2 -0
@@ -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); }
Signature · 1 line
2.20.1
Quoted 6 lines · Ralph Campbell
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 <[email protected]>
Looks good,