Re: [PATCH 08/19] mm: Always define pxx_pgprot()

Jason Gunthorpe
2024-08-14T13:09:19Z

On Fri, Aug 09, 2024 at 12:08:58PM -0400, Peter Xu wrote:
> There're:
>
> - 8 archs (arc, arm64, include, mips, powerpc, s390, sh, x86) that
> support pte_pgprot().
>
> - 2 archs (x86, sparc) that support pmd_pgprot().
>
> - 1 arch (x86) that support pud_pgprot().
>
> Always define them to be used in generic code, and then we don't need to
> fiddle with "#ifdef"s when doing so.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> arch/arm64/include/asm/pgtable.h | 1 +
> arch/powerpc/include/asm/pgtable.h | 1 +
> arch/s390/include/asm/pgtable.h | 1 +
> arch/sparc/include/asm/pgtable_64.h | 1 +
> include/linux/pgtable.h | 12 ++++++++++++
> 5 files changed, 16 insertions(+)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index 7a4f5604be3f..b78cc4a6758b 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -384,6 +384,7 @@ static inline void __sync_cache_and_tags(pte_t pte, unsigned int nr_pages)
> /*
> * Select all bits except the pfn
> */
> +#define pte_pgprot pte_pgprot
> static inline pgprot_t pte_pgprot(pte_t pte)
> {
> unsigned long pfn = pte_pfn(pte);

Stylistically I've been putting the #defines after the function body,
I wonder if there is a common pattern..

Jason