mm/damon: use damon_get_monitor_folio() for hugetlb entries

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.

Link: https://lore.kernel.org/20261006065209.41507-3-sj@kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
This commit is contained in:
Gregory Price 2026-10-05 23:52:06 -07:00 committed by Andrew Morton
parent 0284dff76e
commit 8cb5bfe457
2 changed files with 10 additions and 6 deletions

View File

@ -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,

View File

@ -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);