Re: [PATCH v3 01/10] mm/ppc: Define pXd_large() with pXd_leaf()
On Tue, Mar 05, 2024 at 12:37:41PM +0800, pet...@redhat.com wrote: > From: Peter Xu > > The two definitions are the same. The only difference is that pXd_large() > is only defined with THP selected, and only on book3s 64bits. > > Instead of implementing it twice, make pXd_large() a macro to pXd_leaf(). > Define it unconditionally just like pXd_leaf(). This helps to prepare > merging the two APIs. > > Cc: Michael Ellerman > Cc: Nicholas Piggin > Cc: Christophe Leroy > Cc: "Aneesh Kumar K.V" > Cc: "Naveen N. Rao" > Cc: linuxppc-dev@lists.ozlabs.org > Reviewed-by: Jason Gunthorpe > Signed-off-by: Peter Xu Reviewed-by: Mike Rapoport (IBM) > --- > arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++-- > arch/powerpc/include/asm/pgtable.h | 2 +- > 2 files changed, 3 insertions(+), 15 deletions(-) > > diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h > b/arch/powerpc/include/asm/book3s/64/pgtable.h > index 927d585652bc..d1318e8582ac 100644 > --- a/arch/powerpc/include/asm/book3s/64/pgtable.h > +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h > @@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned > long addr, pud_t *pudp, > return pud_val(*pudp); > } > > -/* > - * returns true for pmd migration entries, THP, devmap, hugetlb > - * But compile time dependent on THP config > - */ > -static inline int pmd_large(pmd_t pmd) > -{ > - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > -} > - > -static inline int pud_large(pud_t pud) > -{ > - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); > -} > - > /* > * For radix we should always find H_PAGE_HASHPTE zero. Hence > * the below will work for radix too > @@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long > old_val, unsigned long new_va > */ > #define pmd_is_leaf pmd_is_leaf > #define pmd_leaf pmd_is_leaf > +#define pmd_large pmd_leaf > static inline bool pmd_is_leaf(pmd_t pmd) > { > return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > @@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd) > > #define pud_is_leaf pud_is_leaf > #define pud_leaf pud_is_leaf > +#define pud_large pud_leaf > static inline bool pud_is_leaf(pud_t pud) > { > return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); > diff --git a/arch/powerpc/include/asm/pgtable.h > b/arch/powerpc/include/asm/pgtable.h > index 7a1ba8889aea..5928b3c1458d 100644 > --- a/arch/powerpc/include/asm/pgtable.h > +++ b/arch/powerpc/include/asm/pgtable.h > @@ -101,7 +101,7 @@ void poking_init(void); > extern unsigned long ioremap_bot; > extern const pgprot_t protection_map[16]; > > -#ifndef CONFIG_TRANSPARENT_HUGEPAGE > +#ifndef pmd_large > #define pmd_large(pmd) 0 > #endif > > -- > 2.44.0 > > -- Sincerely yours, Mike.
Re: [PATCH v3 01/10] mm/ppc: Define pXd_large() with pXd_leaf()
Le 05/03/2024 à 05:37, pet...@redhat.com a écrit : > From: Peter Xu > > The two definitions are the same. The only difference is that pXd_large() > is only defined with THP selected, and only on book3s 64bits. > > Instead of implementing it twice, make pXd_large() a macro to pXd_leaf(). > Define it unconditionally just like pXd_leaf(). This helps to prepare > merging the two APIs. > > Cc: Michael Ellerman > Cc: Nicholas Piggin > Cc: Christophe Leroy > Cc: "Aneesh Kumar K.V" > Cc: "Naveen N. Rao" > Cc: linuxppc-dev@lists.ozlabs.org > Reviewed-by: Jason Gunthorpe > Signed-off-by: Peter Xu Reviewed-by: Christophe Leroy > --- > arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++-- > arch/powerpc/include/asm/pgtable.h | 2 +- > 2 files changed, 3 insertions(+), 15 deletions(-) > > diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h > b/arch/powerpc/include/asm/book3s/64/pgtable.h > index 927d585652bc..d1318e8582ac 100644 > --- a/arch/powerpc/include/asm/book3s/64/pgtable.h > +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h > @@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned > long addr, pud_t *pudp, > return pud_val(*pudp); > } > > -/* > - * returns true for pmd migration entries, THP, devmap, hugetlb > - * But compile time dependent on THP config > - */ > -static inline int pmd_large(pmd_t pmd) > -{ > - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > -} > - > -static inline int pud_large(pud_t pud) > -{ > - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); > -} > - > /* >* For radix we should always find H_PAGE_HASHPTE zero. Hence >* the below will work for radix too > @@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long > old_val, unsigned long new_va >*/ > #define pmd_is_leaf pmd_is_leaf > #define pmd_leaf pmd_is_leaf > +#define pmd_large pmd_leaf > static inline bool pmd_is_leaf(pmd_t pmd) > { > return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > @@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd) > > #define pud_is_leaf pud_is_leaf > #define pud_leaf pud_is_leaf > +#define pud_large pud_leaf > static inline bool pud_is_leaf(pud_t pud) > { > return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); > diff --git a/arch/powerpc/include/asm/pgtable.h > b/arch/powerpc/include/asm/pgtable.h > index 7a1ba8889aea..5928b3c1458d 100644 > --- a/arch/powerpc/include/asm/pgtable.h > +++ b/arch/powerpc/include/asm/pgtable.h > @@ -101,7 +101,7 @@ void poking_init(void); > extern unsigned long ioremap_bot; > extern const pgprot_t protection_map[16]; > > -#ifndef CONFIG_TRANSPARENT_HUGEPAGE > +#ifndef pmd_large > #define pmd_large(pmd) 0 > #endif >
[PATCH v3 01/10] mm/ppc: Define pXd_large() with pXd_leaf()
From: Peter Xu The two definitions are the same. The only difference is that pXd_large() is only defined with THP selected, and only on book3s 64bits. Instead of implementing it twice, make pXd_large() a macro to pXd_leaf(). Define it unconditionally just like pXd_leaf(). This helps to prepare merging the two APIs. Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Aneesh Kumar K.V" Cc: "Naveen N. Rao" Cc: linuxppc-dev@lists.ozlabs.org Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++-- arch/powerpc/include/asm/pgtable.h | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 927d585652bc..d1318e8582ac 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned long addr, pud_t *pudp, return pud_val(*pudp); } -/* - * returns true for pmd migration entries, THP, devmap, hugetlb - * But compile time dependent on THP config - */ -static inline int pmd_large(pmd_t pmd) -{ - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); -} - -static inline int pud_large(pud_t pud) -{ - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); -} - /* * For radix we should always find H_PAGE_HASHPTE zero. Hence * the below will work for radix too @@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va */ #define pmd_is_leaf pmd_is_leaf #define pmd_leaf pmd_is_leaf +#define pmd_large pmd_leaf static inline bool pmd_is_leaf(pmd_t pmd) { return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); @@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd) #define pud_is_leaf pud_is_leaf #define pud_leaf pud_is_leaf +#define pud_large pud_leaf static inline bool pud_is_leaf(pud_t pud) { return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 7a1ba8889aea..5928b3c1458d 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -101,7 +101,7 @@ void poking_init(void); extern unsigned long ioremap_bot; extern const pgprot_t protection_map[16]; -#ifndef CONFIG_TRANSPARENT_HUGEPAGE +#ifndef pmd_large #define pmd_large(pmd) 0 #endif -- 2.44.0