Re: [PATCH v3 05/26] x86: move PAE PMD preallocation defines to header

"Brendan Jackman" <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm
Message-ID <[email protected]>
On Sat Aug 1, 2026 at 12:59 AM BST, Yosry Ahmed wrote:
> On Sun, Jul 26, 2026 at 10:22:38PM +0000, Brendan Jackman wrote:
>> In a subsequent patch these defines will need to be referenced from a new
>> file, move them as a separate patch for easy review.
>> 
>> The comments have style violations (personal pronouns etc), do not fix
>> them as this is just code movement.
>> 
>> No functional change intended.
>> 
>> Signed-off-by: Brendan Jackman <[email protected]>
>
> AFAICT, this is only needed to expose PREALLOCATED_PMDS for
> mm_local_map_to_user() in patch #7. The only usage is a BUILD_BUG_ON().
>
> I wonder if it would be more preferrable to keep the definitions in
> pgtable.c and add a runtime check instead in mm_local_map_to_user(),
> something like:
>
> diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
> index 09b8d8e6a56ea..15055cb80092c 100644
> --- a/arch/x86/include/asm/mmu_context.h
> +++ b/arch/x86/include/asm/mmu_context.h
> @@ -268,7 +268,6 @@ static inline pmd_t *pgd_to_pmd_walk(pgd_t *pgd, unsigned long va)
>
>  static inline int mm_local_map_to_user(struct mm_struct *mm)
>  {
> -       BUILD_BUG_ON(!PREALLOCATED_PMDS);
>         pgd_t *k_pgd = pgd_offset(mm, MM_LOCAL_BASE_ADDR);
>         pgd_t *u_pgd = kernel_to_user_pgdp(k_pgd);
>         pmd_t *k_pmd, *u_pmd;
> @@ -277,6 +276,9 @@ static inline int mm_local_map_to_user(struct mm_struct *mm)
>         k_pmd = pgd_to_pmd_walk(k_pgd, MM_LOCAL_BASE_ADDR);
>         u_pmd = pgd_to_pmd_walk(u_pgd, MM_LOCAL_BASE_ADDR);
>
> +       if (WARN_ON_ONCE(!k_pmd || !u_pmd))
> +               return -EINVAL;
> +
>         BUILD_BUG_ON(MM_LOCAL_END_ADDR - MM_LOCAL_BASE_ADDR > PMD_SIZE);
>
>         /* Preallocate the PTE table so it can be shared. */

Yeah, I'd say that's fine. Will get back to you if I find another reason
why I thought the move was necessary...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.