Skip to contentSkip to conversation

mm-ksm-keep-soft-dirty-when-merging-a-page.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Nov 3 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/ksm: keep soft-dirty when merging a page
has been removed from the -mm tree. Its filename was
mm-ksm-keep-soft-dirty-when-merging-a-page.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Samarth Narang <[email protected]>
Subject: mm/ksm: keep soft-dirty when merging a page
Date: Wed, 21 Oct 2026 11:21:57 -0700

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")
Assisted-by LLM
Cc Xu Xin <[email protected]>
Cc Chengming Zhou <[email protected]>
Cc Peter Xu <[email protected]>
Cc Kiryl Shutsemau <[email protected]>
Cc Mike Rapoport <[email protected]>

---

 mm/ksm.c |    4 ++++
 1 file changed, 4 insertions(+)
mm/ksm.c renamed from mm/ksm.c~mm-ksm-keep-soft-dirty-when-merging-a-page +4 -0
@@ -1463,6 +1463,10 @@ static int replace_page(struct vm_area_s
 		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

_

Patches currently in -mm which might be from [email protected] are