[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240704043132.28501-28-osalvador@suse.de>
Date: Thu, 4 Jul 2024 06:31:14 +0200
From: Oscar Salvador <osalvador@...e.de>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
Peter Xu <peterx@...hat.com>,
Muchun Song <muchun.song@...ux.dev>,
David Hildenbrand <david@...hat.com>,
SeongJae Park <sj@...nel.org>,
Miaohe Lin <linmiaohe@...wei.com>,
Michal Hocko <mhocko@...e.com>,
Matthew Wilcox <willy@...radead.org>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Oscar Salvador <osalvador@...e.de>
Subject: [PATCH 27/45] mm/damon: Create damon_young_pud_entry to handle PUD-mapped hugetlb vmas
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@...e.de>
---
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
Powered by blists - more mailing lists