[RFC PATCH v2 03/20] mm: Provide pmd to pte_leaf_size()
Christophe Leroy
christophe.leroy at csgroup.eu
Wed May 22 20:22:45 AEST 2024
Le 21/05/2024 à 11:39, Oscar Salvador a écrit :
> 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 at csgroup.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:
I like the idea, it doesn't look that bad after all, it avoids changes
to other arches.
>
>
> 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 */
>
>
>
More information about the Linuxppc-dev
mailing list