* [PATCH] mm/damon: use damon_get_monitor_folio() for hugetlb entries
@ 2026-10-02 14:07 Gregory Price (Meta)
2026-10-02 18:11 ` SJ Park
0 siblings, 1 reply; 3+ messages in thread
From: Gregory Price (Meta) @ 2026-10-02 14:07 UTC (permalink / raw)
To: damon; +Cc: linux-mm, linux-kernel, kernel-team, sj, akpm, Gregory Price
From: Gregory Price <gourry@gourry.net>
Hugetlb folio acquisition is open-coded in three places:
- damon_hugetlb_mkold()
- damon_young_hugetlb_entry()
- damon_va_probe_hugetlb_entry()
DAMON already has damon_get_monitor_folio(), which paddr uses to
get monitored LRU and hugetlb folios and to filter them through
damon_folio_acceptable(). These paths bypass that check.
Use that helper in these paths too, so that DAMON acquires hugetlb
folios and applies its acceptance policy in one place.
No functional change intended. All callers reach these paths with a
present hugetlb PTE under the page table lock, so the folio is always
a mapped hugetlb folio and the helper always returns it.
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
---
mm/damon/ops-common.c | 6 ++++--
mm/damon/vaddr.c | 10 ++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index 77366f42b3e5..f986d79391e4 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -140,9 +140,11 @@ void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
{
bool referenced = false;
pte_t entry = huge_ptep_get(mm, addr, pte);
- struct folio *folio = pfn_folio(pte_pfn(entry));
+ struct folio *folio;
- folio_get(folio);
+ folio = damon_get_monitor_folio(pte_pfn(entry));
+ if (!folio)
+ return;
referenced = damon_hugetlb_ptep_mkold(pte, mm, vma, addr, &entry);
if (mmu_notifier_clear_young(mm, addr,
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index d5dde97b3cd0..b549496ea8e2 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -411,8 +411,9 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask,
if (!pte_present(entry))
goto out;
- folio = pfn_folio(pte_pfn(entry));
- folio_get(folio);
+ folio = damon_get_monitor_folio(pte_pfn(entry));
+ if (!folio)
+ goto out;
if (pte_young(entry) || !folio_test_idle(folio) ||
mmu_notifier_test_young(walk->mm, addr))
@@ -660,8 +661,9 @@ static int damon_va_probe_hugetlb_entry(pte_t *pte, unsigned long hmask,
if (!pte_present(entry))
goto out;
- folio = pfn_folio(pte_pfn(entry));
- folio_get(folio);
+ folio = damon_get_monitor_folio(pte_pfn(entry));
+ if (!folio)
+ goto out;
damon_va_probe_folio(priv->ctx, priv->r, folio, &entry, NULL,
walk->vma->vm_mm);
folio_put(folio);
--
2.55.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/damon: use damon_get_monitor_folio() for hugetlb entries
2026-10-02 14:07 [PATCH] mm/damon: use damon_get_monitor_folio() for hugetlb entries Gregory Price (Meta)
@ 2026-10-02 18:11 ` SJ Park
2026-10-02 18:28 ` Gregory Price
0 siblings, 1 reply; 3+ messages in thread
From: SJ Park @ 2026-10-02 18:11 UTC (permalink / raw)
To: Gregory Price (Meta)
Cc: SJ Park, damon, linux-mm, linux-kernel, kernel-team, akpm
Hello Gregory,
On Fri, 2 Oct 2026 10:07:27 -0400 "Gregory Price (Meta)" <gourry@gourry.net> wrote:
> From: Gregory Price <gourry@gourry.net>
>
> Hugetlb folio acquisition is open-coded in three places:
> - damon_hugetlb_mkold()
> - damon_young_hugetlb_entry()
> - damon_va_probe_hugetlb_entry()
>
> DAMON already has damon_get_monitor_folio(), which paddr uses to
> get monitored LRU and hugetlb folios and to filter them through
> damon_folio_acceptable(). These paths bypass that check.
>
> Use that helper in these paths too, so that DAMON acquires hugetlb
> folios and applies its acceptance policy in one place.
>
> No functional change intended. All callers reach these paths with a
> present hugetlb PTE under the page table lock, so the folio is always
> a mapped hugetlb folio and the helper always returns it.
Thank you for this patch, looks good to me!
>
> Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: SJ Park <sj@kernel.org>
This patch is applied to damon/next [1] tree. If this patch is not added to
mm.git in short term (~1 week?), I will ask mm.git maintainer (Andrew Morton)
to pick this. So, no action from your side is needed for now. If it seems I
also forgot doing that or you cannot wait for my action, please feel free to
ping me or Andrew.
[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/damon: use damon_get_monitor_folio() for hugetlb entries
2026-10-02 18:11 ` SJ Park
@ 2026-10-02 18:28 ` Gregory Price
0 siblings, 0 replies; 3+ messages in thread
From: Gregory Price @ 2026-10-02 18:28 UTC (permalink / raw)
To: SJ Park; +Cc: damon, linux-mm, linux-kernel, kernel-team, akpm
On Fri, Oct 02, 2026 at 11:11:35AM -0700, SJ Park wrote:
> Hello Gregory,
>
> This patch is applied to damon/next [1] tree. If this patch is not added to
> mm.git in short term (~1 week?), I will ask mm.git maintainer (Andrew Morton)
> to pick this. So, no action from your side is needed for now. If it seems I
> also forgot doing that or you cannot wait for my action, please feel free to
> ping me or Andrew.
>
All good, thank you SJ!
~Gregory
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-02 18:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 14:07 [PATCH] mm/damon: use damon_get_monitor_folio() for hugetlb entries Gregory Price (Meta)
2026-10-02 18:11 ` SJ Park
2026-10-02 18:28 ` Gregory Price
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®