Re: [PATCH v3] mm/ksm: keep soft-dirty when merging a page

From: Lance Yang

Date: Wed Oct 21 2026 - 20:51:56 EST



On Wed, Oct 21, 2026 at 11:21:57AM -0700, Samarth Narang wrote:
>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.
>
>Fixes: 0f8975ec4db2 ("mm: soft-dirty bits for user memory changes tracking")
>Cc: stable@xxxxxxxxxxxxxxx
>Assisted-by: LLM
>Signed-off-by: Samarth Narang <samarth.colleges@xxxxxxxxx>
>---

LGTM!

Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>