Re: [PATCH v8 03/14] mm: introduce pgtable_has_pmd_leaves()

From: David Hildenbrand (Arm)

Date: Fri Oct 02 2026 - 15:18:08 EST


On 9/18/26 03:45, Luiz Capitulino wrote:
> Currently, we have two helpers that check for PMD-sized pages but have
> different names and slightly different semantics:
>
> - has_transparent_hugepage(): the name suggests it checks if THP is
> enabled, but when CONFIG_TRANSPARENT_HUGEPAGE=y and the architecture
> implements this helper, it actually checks if the CPU supports
> PMD-sized pages
>
> - thp_disabled_by_hw(): the name suggests it checks if THP is disabled
> by the hardware, but it just returns a cached value acquired with
> has_transparent_hugepage() during boot. This helper is used in fast
> paths
>
> A better design would be to separate CONFIG_TRANSPARENT_HUGEPAGE
> checking, which can be done with the IS_ENABLED() macro, from checking
> if a CPU supports PMD-sized pages.
>
> To this end, this commit introduces a new helper called
> pgtable_has_pmd_leaves() which offers the following advantages:
>
> 1. Well defined and clear semantics: it returns true if the CPU
> supports PMD-sized pages and false otherwise
> 2. It always returns a cached value, so it can be used in fast paths
> 3. It's implemented with a static key: it's a no-op for archs not
> implemeting it and for archs implementing it the static key is
> changed only during boot
>
> The new helper requires an initialization step which is performed by
> pgtable_leaf_support_init(). We call pgtable_leaf_support_init() early
> during boot from mm_core_init().
>
> The next commits will convert users of both has_transparent_hugepage()
> and thp_disabled_by_hw() to pgtable_has_pmd_leaves() and/or
> IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE).
>
> Signed-off-by: Luiz Capitulino <luizcap@xxxxxxxxxx>
> ---

Clean, thanks

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David