Normal THP cannot be PUD-mapped (besides devmap), but hugetlb can, so create damon_young_pud_entry in order to handle PUD-mapped hugetlb vmas. Signed-off-by: Oscar Salvador <osalvador@xxxxxxx> --- mm/damon/vaddr.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 00d32beffe38..2d5ad47b9dae 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -434,6 +434,39 @@ struct damon_young_walk_private { bool young; }; +static int damon_young_pud_entry(pmd_t *pud, unsigned long addr, + unsigned long next, struct mm_walk *walk) +{ +#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES + spinlock_t *ptl; + struct folio *folio; + struct damon_young_walk_private *priv = walk->private; + + ptl = pud_huge_lock(vma, pud); + if (!ptl) + return 0; + + if (!pud_present(*pud)) + goto out; + + folio = pfn_folio(pud_pfn(*pud)); + if (!folio) + goto out; + folio_get(folio); + + if (pud_young(pmde) || !folio_test_idle(folio) || + mmu_notifier_test_young(walk->mm, addr)) + priv->young = true; + + *priv->folio_sz = huge_page_size(h); + folio_put(folio); +out: + spin_unlock(ptl); +#endif + return 0; +} + + static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long next, struct mm_walk *walk) { @@ -537,6 +570,7 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask, #endif /* CONFIG_HUGETLB_PAGE */ static const struct mm_walk_ops damon_young_ops = { + .pud_entry = damon_young_pud_entry, .pmd_entry = damon_young_pmd_entry, .hugetlb_entry = damon_young_hugetlb_entry, .walk_lock = PGWALK_RDLOCK, -- 2.26.2