Re: [PATCH v5 03/17] asm-generic: pgalloc: Provide generic p4d_{alloc_one,free}
From: Arnd Bergmann
Date: Wed Jan 08 2025 - 06:02:08 EST
On Wed, Jan 8, 2025, at 07:57, Qi Zheng wrote:
> From: Kevin Brodsky <kevin.brodsky@xxxxxxx>
>
> Four architectures currently implement 5-level pgtables: arm64,
> riscv, x86 and s390. The first three have essentially the same
> implementation for p4d_alloc_one() and p4d_free(), so we've got an
> opportunity to reduce duplication like at the lower levels.
>
> Provide a generic version of p4d_alloc_one() and p4d_free(), and
> make use of it on those architectures.
>
> Their implementation is the same as at PUD level, except that
> p4d_free() performs a runtime check by calling mm_p4d_folded().
> 5-level pgtables depend on a runtime-detected hardware feature on
> all supported architectures, so we might as well include this check
> in the generic implementation. No runtime check is required in
> p4d_alloc_one() as the top-level p4d_alloc() already does the
> required check.
>
> Signed-off-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
> Acked-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Signed-off-by: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
> ---
> arch/arm64/include/asm/pgalloc.h | 17 ------------
> arch/riscv/include/asm/pgalloc.h | 23 ----------------
> arch/x86/include/asm/pgalloc.h | 18 -------------
> include/asm-generic/pgalloc.h | 45 ++++++++++++++++++++++++++++++++
> 4 files changed, 45 insertions(+), 58 deletions(-)
Acked-by: Arnd Bergmann <arnd@xxxxxxxx> # asm-generic