* [PATCH] mm/damon: align MMU notifier range when clearing PMD young bit
@ 2026-10-22 14:26 Aveline Noir
2026-10-23 0:20 ` SJ Park
0 siblings, 1 reply; 2+ messages in thread
From: Aveline Noir @ 2026-10-22 14:26 UTC (permalink / raw)
To: SJ Park, Andrew Morton; +Cc: Shubhang Kaushik, damon, linux-mm, linux-kernel
damon_pmdp_mkold() clears the young bit of a PMD but notifies
[addr, addr + HPAGE_PMD_SIZE), where addr can be an unaligned sampling
address. This can miss part of the sampled huge page and age secondary
mappings in the next one.
Align addr to HPAGE_PMD_MASK so both operations cover the same huge page.
Fixes: 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces")
Link: https://lore.kernel.org/r/20261021-damon-align-pte-young-notifier-v1-1-d0365ac45b66@gentwo.org/
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
---
Tested both aligned and unaligned addresses on 2 MiB THPs in an x86-64 KVM
guest with a recording MMU notifier; all ranges matched the sampled PMD.
DAMON KUnit: 37 passed; selftests: 13 passed, 2 skipped.
mm/damon/ops-common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index 8fc61d0..3b7519b 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -83,6 +83,8 @@ void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr
bool young = false;
unsigned long pfn;
+ addr &= HPAGE_PMD_MASK;
+
if (likely(pmd_present(pmdval)))
pfn = pmd_pfn(pmdval);
else
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] mm/damon: align MMU notifier range when clearing PMD young bit
2026-10-22 14:26 [PATCH] mm/damon: align MMU notifier range when clearing PMD young bit Aveline Noir
@ 2026-10-23 0:20 ` SJ Park
0 siblings, 0 replies; 2+ messages in thread
From: SJ Park @ 2026-10-23 0:20 UTC (permalink / raw)
To: Aveline Noir
Cc: SJ Park, Andrew Morton, Shubhang Kaushik, damon, linux-mm,
linux-kernel, Fernand Sieber, Leonard Foerster, SeongJae Park,
Shakeel Butt
Hello Aveline,
'hkml patch check' [1] says you forgot Cc-ing below people who are recommended
by get_maintainer.pl. I Cc-ed them. Please Cc all recipients who
get_maitnainer.pl is recommending, from the next time. 'hkml patch format' [2]
could also help you doing so.
- Fernand Sieber <sieberf@amazon.com>
- Leonard Foerster <foersleo@amazon.de>
- SeongJae Park <sjpark@amazon.de>
- Shakeel Butt <shakeel.butt@linux.dev>
On Thu, 22 Oct 2026 22:26:08 +0800 Aveline Noir <jm5905938@gmail.com> wrote:
> damon_pmdp_mkold() clears the young bit of a PMD but notifies
> [addr, addr + HPAGE_PMD_SIZE), where addr can be an unaligned sampling
> address. This can miss part of the sampled huge page and age secondary
> mappings in the next one.
>
> Align addr to HPAGE_PMD_MASK so both operations cover the same huge page.
Looks good to me. Thank you for fixing.
>
> Fixes: 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces")
This is an improvement of monitoring accuracy that DAMON provide only best
effort. So not Cc-ing stable@ makes sense to me.
> Link: https://lore.kernel.org/r/20261021-damon-align-pte-young-notifier-v1-1-d0365ac45b66@gentwo.org/
The is a link to Shubhang's pte_mkold() patch. When you add Link: to your
patch, please add a context on the commit message, from the next time.
I assume you added this link because you mentioned you will send this patch on
the thread, with your nice review of the patch. However, I think this patch
explains its context very well, and therefore this link is not needed.
> Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
I applied this patch to damon/next [3] tree after dropping the Link: tag. We
are now in the middle of the merge window. It may be better to give mm.git
maintainer (Andrew Morton) time to work on pull request, rather than adding
more changes that are not really urgent. I understand this series is not
really urgent. Hence, Andrew might not add this patch until next -rc1 release.
In the case, I will request adding this to mm.git after next -rc1 release. Let
me know if you think this is really urgent or the Link: tag should be kept. If
not, no action from your side is needed for now.
> ---
> Tested both aligned and unaligned addresses on 2 MiB THPs in an x86-64 KVM
> guest with a recording MMU notifier; all ranges matched the sampled PMD.
Thank you for doing the test and sharing the results. Were you also able to
confirm the expected wrong behavior (missing part of the sampled huge page and
age secondary mapping), too?
[1] https://github.com/sjp38/hackermail/blob/master/USAGE.md#checking-patches
[2] https://github.com/sjp38/hackermail/blob/master/USAGE.md#formatting-patches
[3] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-23 0:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 14:26 [PATCH] mm/damon: align MMU notifier range when clearing PMD young bit Aveline Noir
2026-10-23 0:20 ` SJ Park
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®