From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Gregory Price <gourry@gourry.net>, SJ Park <sj@kernel.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH 2/3] mm/damon: use damon_get_monitor_folio() for hugetlb entries
Date: Mon, 5 Oct 2026 23:52:06 -0700 [thread overview]
Message-ID: <20261006065209.41507-3-sj@kernel.org> (raw)
In-Reply-To: <20261006065209.41507-1-sj@kernel.org>
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.
Cc: Gregory Price <gourry@gourry.net>
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20261002140727.701709-1-gourry@gourry.net
- Collect R-b: from SJ.
- Rebase to the latest mm-new.
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 7a7429359dc8..2f3bf86a221b 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.47.3
next prev parent reply other threads:[~2026-10-06 6:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 6:52 [PATCH 0/3] mm/damon: fix a minor bug, clean code, and add a test SJ Park
2026-10-06 6:52 ` [PATCH 1/3] mm/damon/ops-common: fix age_in_sec overflow on 32-bit SJ Park
2026-10-06 6:52 ` SJ Park [this message]
2026-10-06 6:52 ` [PATCH 3/3] mm/damon/tests/core-kunit: add test for unconditionally skipping the last region SJ Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261006065209.41507-3-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=gourry@gourry.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®