mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/damon: align MMU notifier range when clearing PTE young bit
@ 2026-10-22  6:36 Shubhang Kaushik (Ampere)
  2026-10-22 14:02 ` SJ Park
  2026-10-22 14:41 ` Aveline Noir
  0 siblings, 2 replies; 3+ messages in thread
From: Shubhang Kaushik (Ampere) @ 2026-10-22  6:36 UTC (permalink / raw)
  To: SJ Park, Andrew Morton, Fernand Sieber, Shakeel Butt,
	SeongJae Park, Leonard Foerster, Shubhang Kaushik,
	Christoph Lameter (Ampere)
  Cc: damon, linux-mm, linux-kernel, Shubhang Kaushik (Ampere)

DAMON selects a byte-granular sampling address.  damon_ptep_mkold()
clears the young bit of the PTE covering that address, but passes the
unaligned range [addr, addr + PAGE_SIZE) to MMU notifiers.

For an unaligned address, that range extends into the following page.
KVM ages every guest page intersecting the notifier range, so it can age
a secondary mapping for the following page although DAMON cleared only
the sampled page's primary PTE.

Align the address before both the primary PTE operation and the
MMU notifier call so that they cover the same page.

Fixes: 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces")
Signed-off-by: Shubhang Kaushik (Ampere) <sh@gentwo.org>
---
 mm/damon/ops-common.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index 8fc61d06d358597c4b8eec9523865f43496298d1..848c327f231e722499b9aac2c041b3aa84061d56 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -46,6 +46,8 @@ void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr
 	bool young = false;
 	unsigned long pfn;
 
+	addr = PAGE_ALIGN_DOWN(addr);
+
 	if (likely(pte_present(pteval)))
 		pfn = pte_pfn(pteval);
 	else
@@ -65,8 +67,7 @@ void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr
 		 * Arch implementation of ptep_test_and_clear_young() may
 		 * require aligned @addr
 		 */
-		young |= ptep_test_and_clear_young(vma, PAGE_ALIGN_DOWN(addr),
-				pte);
+		young |= ptep_test_and_clear_young(vma, addr, pte);
 	young |= mmu_notifier_clear_young(vma->vm_mm, addr, addr + PAGE_SIZE);
 	if (young)
 		folio_set_young(folio);

---
base-commit: 4403278e4ea2f654f8130a5c03eb8b4516a0f201
change-id: 20261021-damon-align-pte-young-notifier-e8f19e0e84c5

Best regards,
-- 
Shubhang Kaushik (Ampere) <sh@gentwo.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-22 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22  6:36 [PATCH] mm/damon: align MMU notifier range when clearing PTE young bit Shubhang Kaushik (Ampere)
2026-10-22 14:02 ` SJ Park
2026-10-22 14:41 ` Aveline Noir

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®