mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mm/ksm: keep soft-dirty when merging a page
replace_page() maps the KSM page with a PTE built from scratch, so the
soft-dirty bit of the PTE it replaces is lost. A page written since
"clear_refs 4" then no longer shows as soft-dirty once it is merged, and a
soft-dirty based dumper treats it as unchanged.
Copy the soft-dirty bit from the original PTE to the new PTE.
Link: https://lore.kernel.org/20261021182157.1873726-1-samarth.colleges@gmail.com
Fixes: 0f8975ec4d ("mm: soft-dirty bits for user memory changes tracking")
Signed-off-by: Samarth Narang <samarth.colleges@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Assisted-by: LLM
Cc: Xu Xin <xu.xin@linux.dev>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Peter Xu <peterx@redhat.com>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: <stable@vger.kernel.org>
This commit is contained in:
parent
c386d799f4
commit
2efc6332f1
4
mm/ksm.c
4
mm/ksm.c
|
|
@ -1463,6 +1463,10 @@ static int replace_page(struct vm_area_struct *vma, struct page *page,
|
|||
dec_mm_counter(mm, MM_ANONPAGES);
|
||||
}
|
||||
|
||||
/* Preserve soft-dirty when replacing the page. */
|
||||
if (pte_soft_dirty(orig_pte))
|
||||
newpte = pte_mksoft_dirty(newpte);
|
||||
|
||||
flush_cache_page(vma, addr, pte_pfn(ptep_get(ptep)));
|
||||
/*
|
||||
* No need to notify as we are replacing a read only page with another
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user