From: Mike Rapoport <rppt@kernel.org>
To: peterx@redhat.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Christophe Leroy <christophe.leroy@csgroup.eu>,
x86@kernel.org, "Kirill A . Shutemov" <kirill@shutemov.name>,
Jason Gunthorpe <jgg@nvidia.com>, Yang Shi <shy828301@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
linuxppc-dev@lists.ozlabs.org,
Muchun Song <muchun.song@linux.dev>
Subject: Re: [PATCH v3 10/10] mm/treewide: Align up pXd_leaf() retval across archs
Date: Wed, 6 Mar 2024 08:35:52 +0200 [thread overview]
Message-ID: <ZegOyFS6aQC7StG_@kernel.org> (raw)
In-Reply-To: <20240305043750.93762-11-peterx@redhat.com>
On Tue, Mar 05, 2024 at 12:37:50PM +0800, peterx@redhat.com wrote:
> From: Peter Xu <peterx@redhat.com>
>
> Even if pXd_leaf() API is defined globally, it's not clear on the retval,
> and there are three types used (bool, int, unsigned log).
>
> Always return a boolean for pXd_leaf() APIs.
>
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
> ---
> arch/riscv/include/asm/pgtable-64.h | 2 +-
> arch/riscv/include/asm/pgtable.h | 2 +-
> arch/s390/include/asm/pgtable.h | 4 ++--
> arch/sparc/include/asm/pgtable_64.h | 4 ++--
> arch/x86/include/asm/pgtable.h | 8 ++++----
> include/linux/pgtable.h | 8 ++++----
> 6 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h
> index b42017d76924..2c7e1661db01 100644
> --- a/arch/riscv/include/asm/pgtable-64.h
> +++ b/arch/riscv/include/asm/pgtable-64.h
> @@ -190,7 +190,7 @@ static inline int pud_bad(pud_t pud)
> }
>
> #define pud_leaf pud_leaf
> -static inline int pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
> {
> return pud_present(pud) && (pud_val(pud) & _PAGE_LEAF);
> }
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index add5cd30ab34..6839520dbcb1 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -241,7 +241,7 @@ static inline int pmd_bad(pmd_t pmd)
> }
>
> #define pmd_leaf pmd_leaf
> -static inline int pmd_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
> {
> return pmd_present(pmd) && (pmd_val(pmd) & _PAGE_LEAF);
> }
> diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> index 9e08af5b9247..60950e7a25f5 100644
> --- a/arch/s390/include/asm/pgtable.h
> +++ b/arch/s390/include/asm/pgtable.h
> @@ -706,7 +706,7 @@ static inline int pud_none(pud_t pud)
> }
>
> #define pud_leaf pud_leaf
> -static inline int pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
> {
> if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3)
> return 0;
> @@ -714,7 +714,7 @@ static inline int pud_leaf(pud_t pud)
> }
>
> #define pmd_leaf pmd_leaf
> -static inline int pmd_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
> {
> return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) != 0;
> }
> diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
> index 6ff0a28d5fd1..4d1bafaba942 100644
> --- a/arch/sparc/include/asm/pgtable_64.h
> +++ b/arch/sparc/include/asm/pgtable_64.h
> @@ -681,7 +681,7 @@ static inline unsigned long pte_special(pte_t pte)
> }
>
> #define pmd_leaf pmd_leaf
> -static inline unsigned long pmd_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
> {
> pte_t pte = __pte(pmd_val(pmd));
>
> @@ -868,7 +868,7 @@ static inline pmd_t *pud_pgtable(pud_t pud)
> #define p4d_page(p4d) NULL
>
> #define pud_leaf pud_leaf
> -static inline unsigned long pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
> {
> pte_t pte = __pte(pud_val(pud));
>
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index cfc84c55d0e6..7621a5acb13e 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -252,7 +252,7 @@ static inline unsigned long pgd_pfn(pgd_t pgd)
> }
>
> #define p4d_leaf p4d_leaf
> -static inline int p4d_leaf(p4d_t p4d)
> +static inline bool p4d_leaf(p4d_t p4d)
> {
> /* No 512 GiB pages yet */
> return 0;
> @@ -261,7 +261,7 @@ static inline int p4d_leaf(p4d_t p4d)
> #define pte_page(pte) pfn_to_page(pte_pfn(pte))
>
> #define pmd_leaf pmd_leaf
> -static inline int pmd_leaf(pmd_t pte)
> +static inline bool pmd_leaf(pmd_t pte)
> {
> return pmd_flags(pte) & _PAGE_PSE;
> }
> @@ -1086,7 +1086,7 @@ static inline pmd_t *pud_pgtable(pud_t pud)
> #define pud_page(pud) pfn_to_page(pud_pfn(pud))
>
> #define pud_leaf pud_leaf
> -static inline int pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
> {
> return (pud_val(pud) & (_PAGE_PSE | _PAGE_PRESENT)) ==
> (_PAGE_PSE | _PAGE_PRESENT);
> @@ -1413,7 +1413,7 @@ static inline bool pgdp_maps_userspace(void *__ptr)
> }
>
> #define pgd_leaf pgd_leaf
> -static inline int pgd_leaf(pgd_t pgd) { return 0; }
> +static inline bool pgd_leaf(pgd_t pgd) { return false; }
>
> #ifdef CONFIG_PAGE_TABLE_ISOLATION
> /*
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index a36cf4e124b0..85fc7554cd52 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -1777,16 +1777,16 @@ typedef unsigned int pgtbl_mod_mask;
> * Only meaningful when called on a valid entry.
> */
> #ifndef pgd_leaf
> -#define pgd_leaf(x) 0
> +#define pgd_leaf(x) false
> #endif
> #ifndef p4d_leaf
> -#define p4d_leaf(x) 0
> +#define p4d_leaf(x) false
> #endif
> #ifndef pud_leaf
> -#define pud_leaf(x) 0
> +#define pud_leaf(x) false
> #endif
> #ifndef pmd_leaf
> -#define pmd_leaf(x) 0
> +#define pmd_leaf(x) false
> #endif
>
> #ifndef pgd_leaf_size
> --
> 2.44.0
>
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2024-03-06 6:36 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 4:37 [PATCH v3 00/10] mm/treewide: Replace pXd_large() with pXd_leaf() peterx
2024-03-05 4:37 ` [PATCH v3 01/10] mm/ppc: Define " peterx
2024-03-05 17:29 ` Christophe Leroy
2024-03-06 6:15 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 02/10] mm/ppc: Replace pXd_is_leaf() " peterx
2024-03-05 17:31 ` Christophe Leroy
2024-03-06 6:20 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 03/10] mm/x86: Replace p4d_large() with p4d_leaf() peterx
2024-03-06 6:23 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 04/10] mm/x86: Replace pgd_large() with pgd_leaf() peterx
2024-03-05 16:05 ` Jason Gunthorpe
2024-03-06 6:23 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 05/10] mm/x86: Drop two unnecessary pud_leaf() definitions peterx
2024-03-06 6:27 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 06/10] mm/kasan: Use pXd_leaf() in shadow_mapped() peterx
2024-03-06 6:28 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 07/10] mm/treewide: Replace pmd_large() with pmd_leaf() peterx
2024-03-06 6:31 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 08/10] mm/treewide: Replace pud_large() with pud_leaf() peterx
2024-03-05 4:37 ` [PATCH v3 09/10] mm/treewide: Drop pXd_large() peterx
2024-03-06 6:34 ` Mike Rapoport
2024-03-05 4:37 ` [PATCH v3 10/10] mm/treewide: Align up pXd_leaf() retval across archs peterx
2024-03-05 14:33 ` Jason Gunthorpe
2024-03-06 6:35 ` Mike Rapoport [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZegOyFS6aQC7StG_@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=christophe.leroy@csgroup.eu \
--cc=jgg@nvidia.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=muchun.song@linux.dev \
--cc=peterx@redhat.com \
--cc=shy828301@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox