* Re: [PATCH v8 09/14] powerpc: move has_transparent_hugepage() out of THP guard
[not found] ` <25bb02df-a795-4e48-9de6-99f1ca799176@redhat.com>
@ 2026-10-05 4:52 ` Christophe Leroy (CS GROUP)
2026-10-05 20:40 ` Luiz Capitulino
0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-10-05 4:52 UTC (permalink / raw)
To: Luiz Capitulino, David Hildenbrand (Arm), linux-kernel, linux-mm,
baolin.wang, ziy, lance.yang, linuxppc-dev@lists.ozlabs.org
Cc: corbet, tsbogend, maddy, mpe, agordeev, gerald.schaefer, hca, gor,
x86, tglx, mingo, bp, hughd, dave.hansen, djbw, vishal.l.verma,
dave.jiang, akpm, yintirui, dev.jain, usama.arif
Hi,
Don't forget <linuxppc-dev@lists.ozlabs.org> when you address powerpc
architecture.
Le 03/10/2026 à 17:44, Luiz Capitulino a écrit :
>
>
> On 10/2/26 3:28 PM, David Hildenbrand (Arm) wrote:
>> On 9/18/26 03:45, Luiz Capitulino wrote:
>>> A future commit will introduce a kernel API to allow for checking if the
>>> CPU supports PMD-sized pages. This API will be based on the
>>> has_transparent_hugepage() implementation but will be orthogonal to THP
>>> and therefore must work when CONFIG_TRANSPARENT_HUGEPAGE=n.
>>>
>>> Move its definition out of the THP guard.
>>>
>>> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
>>> ---
>>> arch/powerpc/include/asm/book3s/64/hash-4k.h | 2 +-
>>> arch/powerpc/include/asm/book3s/64/hash-64k.h | 2 +-
>>> arch/powerpc/include/asm/book3s/64/pgtable.h | 18 +++++++++---------
>>> arch/powerpc/include/asm/book3s/64/radix.h | 14 +++++++-------
>>> arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++--
>>> 5 files changed, 20 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/
>>> powerpc/include/asm/book3s/64/hash-4k.h
>>> index 8e5bd9902bed..79511e6abfca 100644
>>> --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
>>> +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
>>> @@ -165,9 +165,9 @@ extern void
>>> hash__pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
>>> extern pgtable_t hash__pgtable_trans_huge_withdraw(struct mm_struct
>>> *mm, pmd_t *pmdp);
>>> extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
>>> unsigned long addr, pmd_t *pmdp);
>>> -extern int hash__has_transparent_hugepage(void);
>>> #endif
>>> +extern int hash__has_transparent_hugepage(void);
>>> #endif /* !__ASSEMBLER__ */
>>> #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */
>>> diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/
>>> powerpc/include/asm/book3s/64/hash-64k.h
>>> index 7deb3a66890b..a4a44a112ff9 100644
>>> --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
>>> +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
>>> @@ -278,9 +278,9 @@ extern void
>>> hash__pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
>>> extern pgtable_t hash__pgtable_trans_huge_withdraw(struct mm_struct
>>> *mm, pmd_t *pmdp);
>>> extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
>>> unsigned long addr, pmd_t *pmdp);
>>> -extern int hash__has_transparent_hugepage(void);
>>
>> Without some of these helpers in place, I assume actually using PMD leafs
>> without THP would require some more work. (which is not the goal of
>> this series,
>> just asking).
>
> Yes, you're right.
>
>> I do wonder whether the architecture should instead simply say "not
>> supported"
>> if !CONFIG_TRANSPARENT_HUGEPAGE?
>>
>> That should still enable your series: using mTHP without PMD support.
>
> Yes, it would. However, I think this introduces an inconsistency.
powerpc has two types of MMU (HASH and RADIX) with different page
layout. MMU type is selected at boottime based on the capabilities of
the CPU. For transparent page you have:
static inline int has_transparent_hugepage(void)
{
if (radix_enabled())
return radix__has_transparent_hugepage();
return hash__has_transparent_hugepage();
}
>
> In in its current form, arch_has_pmd_leaves() should always report a
> hardware
> capability. This is true even for the default case where
> arch_has_pmd_leaves() defaults to
> IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE) in the assumption that
> archs supporting PMD-sized pages by default will have this config
> enabled.
>
> Your suggestion will change this and for some archs
> arch_has_pmd_leaves() may have different behavior depending on the user
> configuration. Additionally, I intended to decouple the base API
> implementation from THP.
>
> If you feel strongly about this I can implement your suggestion, but I'd
> still vote for keeping the API about consistently reporting the hardware
> capability. Even if the only user is THP code today, new use cases can
> be added incrementally.
>
>>
>> [...]
>>
>>> -static inline int radix__has_transparent_hugepage(void)
>>> +static inline int radix__has_transparent_pud_hugepage(void)
>>> {
>>> - /* For radix 2M at PMD level means thp */
>>> - if (mmu_psize_defs[MMU_PAGE_2M].shift == PMD_SHIFT)
>>> + /* For radix 1G at PUD level means pud hugepage support */
>>> + if (mmu_psize_defs[MMU_PAGE_1G].shift == PUD_SHIFT)
>>> return 1;
>>> return 0;
>>> }
>>> +#endif
>>> -static inline int radix__has_transparent_pud_hugepage(void)
>>> +static inline int radix__has_transparent_hugepage(void)
>>> {
>>> - /* For radix 1G at PUD level means pud hugepage support */
>>> - if (mmu_psize_defs[MMU_PAGE_1G].shift == PUD_SHIFT)
>>> + /* For radix 2M at PMD level means thp */
>>> + if (mmu_psize_defs[MMU_PAGE_2M].shift == PMD_SHIFT)
>>> return 1;
>>> return 0;
>>> }
>>
>> You are swapping both implementations, which might create some
>> unnecessary churn
>> I think.
>
> I suspect this was done by git diff as I just moved the functions, but
> I'll take a better look.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v8 09/14] powerpc: move has_transparent_hugepage() out of THP guard
2026-10-05 4:52 ` [PATCH v8 09/14] powerpc: move has_transparent_hugepage() out of THP guard Christophe Leroy (CS GROUP)
@ 2026-10-05 20:40 ` Luiz Capitulino
2026-10-06 4:48 ` Christophe Leroy (CS GROUP)
0 siblings, 1 reply; 3+ messages in thread
From: Luiz Capitulino @ 2026-10-05 20:40 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP), David Hildenbrand (Arm),
linux-kernel, linux-mm, baolin.wang, ziy, lance.yang,
linuxppc-dev@lists.ozlabs.org
Cc: corbet, tsbogend, maddy, mpe, agordeev, gerald.schaefer, hca, gor,
x86, tglx, mingo, bp, hughd, dave.hansen, djbw, vishal.l.verma,
dave.jiang, akpm, yintirui, dev.jain, usama.arif
On 10/5/26 12:52 AM, Christophe Leroy (CS GROUP) wrote:
> Hi,
>
> Don't forget <linuxppc-dev@lists.ozlabs.org> when you address powerpc architecture.
Will do.
>
> Le 03/10/2026 à 17:44, Luiz Capitulino a écrit :
>>
>>
>> On 10/2/26 3:28 PM, David Hildenbrand (Arm) wrote:
>>> On 9/18/26 03:45, Luiz Capitulino wrote:
>>>> A future commit will introduce a kernel API to allow for checking if the
>>>> CPU supports PMD-sized pages. This API will be based on the
>>>> has_transparent_hugepage() implementation but will be orthogonal to THP
>>>> and therefore must work when CONFIG_TRANSPARENT_HUGEPAGE=n.
>>>>
>>>> Move its definition out of the THP guard.
>>>>
>>>> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
>>>> ---
>>>> arch/powerpc/include/asm/book3s/64/hash-4k.h | 2 +-
>>>> arch/powerpc/include/asm/book3s/64/hash-64k.h | 2 +-
>>>> arch/powerpc/include/asm/book3s/64/pgtable.h | 18 +++++++++---------
>>>> arch/powerpc/include/asm/book3s/64/radix.h | 14 +++++++-------
>>>> arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++--
>>>> 5 files changed, 20 insertions(+), 20 deletions(-)
>>>>
>>>> diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/ powerpc/include/asm/book3s/64/hash-4k.h
>>>> index 8e5bd9902bed..79511e6abfca 100644
>>>> --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
>>>> +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
>>>> @@ -165,9 +165,9 @@ extern void hash__pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
>>>> extern pgtable_t hash__pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
>>>> extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
>>>> unsigned long addr, pmd_t *pmdp);
>>>> -extern int hash__has_transparent_hugepage(void);
>>>> #endif
>>>> +extern int hash__has_transparent_hugepage(void);
>>>> #endif /* !__ASSEMBLER__ */
>>>> #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */
>>>> diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/ powerpc/include/asm/book3s/64/hash-64k.h
>>>> index 7deb3a66890b..a4a44a112ff9 100644
>>>> --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
>>>> +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
>>>> @@ -278,9 +278,9 @@ extern void hash__pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
>>>> extern pgtable_t hash__pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
>>>> extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
>>>> unsigned long addr, pmd_t *pmdp);
>>>> -extern int hash__has_transparent_hugepage(void);
>>>
>>> Without some of these helpers in place, I assume actually using PMD leafs
>>> without THP would require some more work. (which is not the goal of this series,
>>> just asking).
>>
>> Yes, you're right.
>>
>>> I do wonder whether the architecture should instead simply say "not supported"
>>> if !CONFIG_TRANSPARENT_HUGEPAGE?
>>>
>>> That should still enable your series: using mTHP without PMD support.
>>
>> Yes, it would. However, I think this introduces an inconsistency.
>
> powerpc has two types of MMU (HASH and RADIX) with different page layout. MMU type is selected at boottime based on the capabilities of the CPU. For transparent page you have:
>
> static inline int has_transparent_hugepage(void)
> {
> if (radix_enabled())
> return radix__has_transparent_hugepage();
> return hash__has_transparent_hugepage();
> }
Right and, unless I'm misunderstanding your comment, this supports my
position that the new arch_has_pmd_leaves() API is all about reporting a
hardware capability and not tied to THP support.
>
>>
>> In in its current form, arch_has_pmd_leaves() should always report a hardware
>> capability. This is true even for the default case where
>> arch_has_pmd_leaves() defaults to
>> IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE) in the assumption that
>> archs supporting PMD-sized pages by default will have this config
>> enabled.
>>
>> Your suggestion will change this and for some archs
>> arch_has_pmd_leaves() may have different behavior depending on the user
>> configuration. Additionally, I intended to decouple the base API
>> implementation from THP.
>>
>> If you feel strongly about this I can implement your suggestion, but I'd
>> still vote for keeping the API about consistently reporting the hardware
>> capability. Even if the only user is THP code today, new use cases can
>> be added incrementally.
>>
>>>
>>> [...]
>>>
>>>> -static inline int radix__has_transparent_hugepage(void)
>>>> +static inline int radix__has_transparent_pud_hugepage(void)
>>>> {
>>>> - /* For radix 2M at PMD level means thp */
>>>> - if (mmu_psize_defs[MMU_PAGE_2M].shift == PMD_SHIFT)
>>>> + /* For radix 1G at PUD level means pud hugepage support */
>>>> + if (mmu_psize_defs[MMU_PAGE_1G].shift == PUD_SHIFT)
>>>> return 1;
>>>> return 0;
>>>> }
>>>> +#endif
>>>> -static inline int radix__has_transparent_pud_hugepage(void)
>>>> +static inline int radix__has_transparent_hugepage(void)
>>>> {
>>>> - /* For radix 1G at PUD level means pud hugepage support */
>>>> - if (mmu_psize_defs[MMU_PAGE_1G].shift == PUD_SHIFT)
>>>> + /* For radix 2M at PMD level means thp */
>>>> + if (mmu_psize_defs[MMU_PAGE_2M].shift == PMD_SHIFT)
>>>> return 1;
>>>> return 0;
>>>> }
>>>
>>> You are swapping both implementations, which might create some unnecessary churn
>>> I think.
>>
>> I suspect this was done by git diff as I just moved the functions, but
>> I'll take a better look.
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v8 09/14] powerpc: move has_transparent_hugepage() out of THP guard
2026-10-05 20:40 ` Luiz Capitulino
@ 2026-10-06 4:48 ` Christophe Leroy (CS GROUP)
0 siblings, 0 replies; 3+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-10-06 4:48 UTC (permalink / raw)
To: Luiz Capitulino, David Hildenbrand (Arm), linux-kernel, linux-mm,
baolin.wang, ziy, lance.yang, linuxppc-dev@lists.ozlabs.org
Cc: corbet, tsbogend, maddy, mpe, agordeev, gerald.schaefer, hca, gor,
x86, tglx, mingo, bp, hughd, dave.hansen, djbw, vishal.l.verma,
dave.jiang, akpm, yintirui, dev.jain, usama.arif
Le 05/10/2026 à 22:40, Luiz Capitulino a écrit :
>
>
> On 10/5/26 12:52 AM, Christophe Leroy (CS GROUP) wrote:
>> Hi,
>>
>> Don't forget <linuxppc-dev@lists.ozlabs.org> when you address powerpc
>> architecture.
>
> Will do.
>
>>
>> Le 03/10/2026 à 17:44, Luiz Capitulino a écrit :
>>>
>>>
>>> On 10/2/26 3:28 PM, David Hildenbrand (Arm) wrote:
>>>> On 9/18/26 03:45, Luiz Capitulino wrote:
>>>>> A future commit will introduce a kernel API to allow for checking
>>>>> if the
>>>>> CPU supports PMD-sized pages. This API will be based on the
>>>>> has_transparent_hugepage() implementation but will be orthogonal to
>>>>> THP
>>>>> and therefore must work when CONFIG_TRANSPARENT_HUGEPAGE=n.
>>>>>
>>>>> Move its definition out of the THP guard.
>>>>>
>>>>> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
>>>>> ---
>>>>> arch/powerpc/include/asm/book3s/64/hash-4k.h | 2 +-
>>>>> arch/powerpc/include/asm/book3s/64/hash-64k.h | 2 +-
>>>>> arch/powerpc/include/asm/book3s/64/pgtable.h | 18 ++++++++
>>>>> +---------
>>>>> arch/powerpc/include/asm/book3s/64/radix.h | 14 +++++++-------
>>>>> arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++--
>>>>> 5 files changed, 20 insertions(+), 20 deletions(-)
>>>>>
>>>>> diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/
>>>>> powerpc/include/asm/book3s/64/hash-4k.h
>>>>> index 8e5bd9902bed..79511e6abfca 100644
>>>>> --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
>>>>> +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
>>>>> @@ -165,9 +165,9 @@ extern void
>>>>> hash__pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
>>>>> extern pgtable_t hash__pgtable_trans_huge_withdraw(struct
>>>>> mm_struct *mm, pmd_t *pmdp);
>>>>> extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
>>>>> unsigned long addr, pmd_t *pmdp);
>>>>> -extern int hash__has_transparent_hugepage(void);
>>>>> #endif
>>>>> +extern int hash__has_transparent_hugepage(void);
>>>>> #endif /* !__ASSEMBLER__ */
>>>>> #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */
>>>>> diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/
>>>>> powerpc/include/asm/book3s/64/hash-64k.h
>>>>> index 7deb3a66890b..a4a44a112ff9 100644
>>>>> --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
>>>>> +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
>>>>> @@ -278,9 +278,9 @@ extern void
>>>>> hash__pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
>>>>> extern pgtable_t hash__pgtable_trans_huge_withdraw(struct
>>>>> mm_struct *mm, pmd_t *pmdp);
>>>>> extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm,
>>>>> unsigned long addr, pmd_t *pmdp);
>>>>> -extern int hash__has_transparent_hugepage(void);
>>>>
>>>> Without some of these helpers in place, I assume actually using PMD
>>>> leafs
>>>> without THP would require some more work. (which is not the goal of
>>>> this series,
>>>> just asking).
>>>
>>> Yes, you're right.
>>>
>>>> I do wonder whether the architecture should instead simply say "not
>>>> supported"
>>>> if !CONFIG_TRANSPARENT_HUGEPAGE?
>>>>
>>>> That should still enable your series: using mTHP without PMD support.
>>>
>>> Yes, it would. However, I think this introduces an inconsistency.
>>
>> powerpc has two types of MMU (HASH and RADIX) with different page
>> layout. MMU type is selected at boottime based on the capabilities of
>> the CPU. For transparent page you have:
>>
>> static inline int has_transparent_hugepage(void)
>> {
>> if (radix_enabled())
>> return radix__has_transparent_hugepage();
>> return hash__has_transparent_hugepage();
>> }
>
> Right and, unless I'm misunderstanding your comment, this supports my
> position that the new arch_has_pmd_leaves() API is all about reporting a
> hardware capability and not tied to THP support.
Yes my comment was in reaction of comment below, I wanted to say that
CONFIG_TRANSPARENT_HUGEPAGE is not always enough to tell if a powerpc
actually has transparent hugepages or not.
>>>> I do wonder whether the architecture should instead simply say "not
>>>> supported"
>>>> if !CONFIG_TRANSPARENT_HUGEPAGE?
>>>>
>>>> That should still enable your series: using mTHP without PMD support.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-06 4:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1789695931.git.luizcap@redhat.com>
[not found] ` <05a71b6011a6eab7b096f262485fcb8b4987976f.1789695931.git.luizcap@redhat.com>
[not found] ` <f54d5d75-5cc1-488b-b640-76163419cf4d@kernel.org>
[not found] ` <25bb02df-a795-4e48-9de6-99f1ca799176@redhat.com>
2026-10-05 4:52 ` [PATCH v8 09/14] powerpc: move has_transparent_hugepage() out of THP guard Christophe Leroy (CS GROUP)
2026-10-05 20:40 ` Luiz Capitulino
2026-10-06 4:48 ` Christophe Leroy (CS GROUP)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox