Skip to contentSkip to conversation

mm, /proc/pid/pagemap: fix soft dirty marking for PMD migration entry

PATCH New [email protected] 1 participant 1 message Nov 2, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 2/7 mm, /proc/pid/pagemap: fix soft dirty marking for PMD migration entry

From: Huang Ying <[email protected]>
Subject: mm, /proc/pid/pagemap: fix soft dirty marking for PMD migration entry

Now, when the page table is walked in the implementation of /proc/<pid>/pagemap, pmd_soft_dirty() is used for both the PMD huge page map and the PMD migration entries. That is wrong, pmd_swp_soft_dirty() should be used for the PMD migration entries instead because the different page table entry flag is used.

As a result, /proc/pid/pagemap may report incorrect soft dirty information for PMD migration entries.

Fixes 84c3fc4e9c56 ("mm: thp: check pmd migration entry in common path")
Cc Michal Hocko <[email protected]>
Cc David Rientjes <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
Cc Daniel Colascione <[email protected]>
Cc Zi Yan <[email protected]>
Cc Anshuman Khandual <[email protected]>

---

 fs/proc/task_mmu.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/proc/task_mmu.c renamed from fs/proc/task_mmu.c~mm-pagemap-fix-soft-dirty-marking-for-pmd-migration-entry +5 -1
diff -puN fs/proc/task_mmu.c~mm-pagemap-fix-soft-dirty-marking-for-pmd-migration-entry fs/proc/task_mmu.c
@@ -1311,13 +1311,15 @@ static int pagemap_pmd_range(pmd_t *pmdp
 		pmd_t pmd = *pmdp;
 		struct page *page = NULL;
 
-		if ((vma->vm_flags & VM_SOFTDIRTY) || pmd_soft_dirty(pmd))
+		if (vma->vm_flags & VM_SOFTDIRTY)
 			flags |= PM_SOFT_DIRTY;
 
 		if (pmd_present(pmd)) {
 			page = pmd_page(pmd);
 
 			flags |= PM_PRESENT;
+			if (pmd_soft_dirty(pmd))
+				flags |= PM_SOFT_DIRTY;
 			if (pm->show_pfn)
 				frame = pmd_pfn(pmd) +
 					((addr & ~PMD_MASK) >> PAGE_SHIFT);
@@ -1329,6 +1331,8 @@ static int pagemap_pmd_range(pmd_t *pmdp
 			frame = swp_type(entry) |
 				(swp_offset(entry) << MAX_SWAPFILES_SHIFT);
 			flags |= PM_SWAP;
+			if (pmd_swp_soft_dirty(pmd))
+				flags |= PM_SOFT_DIRTY;
 			VM_BUG_ON(!is_pmd_migration_entry(pmd));
 			page = migration_entry_to_page(entry);
 		}

_