[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZkxrzrD5aJbqTq2Z@localhost.localdomain>
Date: Tue, 21 May 2024 11:39:26 +0200
From: Oscar Salvador <osalvador@...e.de>
To: Christophe Leroy <christophe.leroy@...roup.eu>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Jason Gunthorpe <jgg@...dia.com>, Peter Xu <peterx@...hat.com>,
Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [RFC PATCH v2 03/20] mm: Provide pmd to pte_leaf_size()
On Fri, May 17, 2024 at 08:59:57PM +0200, Christophe Leroy wrote:
> On powerpc 8xx, when a page is 8M size, the information is in the PMD
> entry. So provide it to pte_leaf_size().
>
> Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
Overall looks good to me.
Would be nicer if we could left the arch code untouched.
I wanted to see how this would be if we go down that road and focus only
on 8xx at the risk of being more esoteric.
pmd_pte_leaf_size() is a name of hell, but could be replaced
with __pte_leaf_size for example.
Worth it? Maybe not, anyway, just wanted to give it a go:
diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
index 137dc3c84e45..9e3fe6e1083f 100644
--- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
@@ -151,7 +151,7 @@ static inline unsigned long pgd_leaf_size(pgd_t pgd)
#define pgd_leaf_size pgd_leaf_size
-static inline unsigned long pte_leaf_size(pte_t pte)
+static inline unsigned long pmd_pte_leaf_size(pte_t pte)
{
pte_basic_t val = pte_val(pte);
@@ -162,7 +162,7 @@ static inline unsigned long pte_leaf_size(pte_t pte)
return SZ_4K;
}
-#define pte_leaf_size pte_leaf_size
+#define pmd_pte_leaf_size pmd_pte_leaf_size
/*
* On the 8xx, the page tables are a bit special. For 16k pages, we have
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 18019f037bae..2bc2fe3b2b53 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -1891,6 +1891,9 @@ typedef unsigned int pgtbl_mod_mask;
#ifndef pte_leaf_size
#define pte_leaf_size(x) PAGE_SIZE
#endif
+#ifndef pmd_pte_leaf_size
+#define pmd_pte_leaf_size(x, y) pte_leaf_size(y)
+#endif
/*
* We always define pmd_pfn for all archs as it's used in lots of generic
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f0128c5ff278..e90a547d2fb2 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7596,7 +7596,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
pte = ptep_get_lockless(ptep);
if (pte_present(pte))
- size = pte_leaf_size(pte);
+ size = pmd_pte_leaf_size(pmd, pte);
pte_unmap(ptep);
#endif /* CONFIG_HAVE_GUP_FAST */
--
Oscar Salvador
SUSE Labs
Powered by blists - more mailing lists