public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Kevin Brodsky <kevin.brodsky@arm.com>,
	linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
	"David Hildenbrand (Arm)" <david@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH] arm64: mm: Use generic enum pgtable_level
Date: Mon, 16 Mar 2026 14:22:11 +0000	[thread overview]
Message-ID: <415ea4a5-e729-4fe5-b95d-29fcca8f7dbd@arm.com> (raw)
In-Reply-To: <20260316140150.58207-1-kevin.brodsky@arm.com>

On 16/03/2026 14:01, Kevin Brodsky wrote:
> enum pgtable_type was introduced for arm64 by commit c64f46ee1377
> ("arm64: mm: use enum to identify pgtable level instead of
> *_SHIFT"). In the meantime, the generic enum pgtable_level got
> introduced by commit b22cc9a9c7ff ("mm/rmap: convert "enum
> rmap_level" to "enum pgtable_level"").
> 
> Let's switch to the generic enum pgtable_level. The only difference
> is that it also includes PGD level - this isn't relevant in
> __pgd_pgtable_alloc() so we just add a default statement.
> 
> Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
> ---
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Will Deacon <will@kernel.org>
> ---
>  arch/arm64/include/asm/mmu.h |  7 -----
>  arch/arm64/mm/mmu.c          | 58 +++++++++++++++++++-----------------
>  2 files changed, 30 insertions(+), 35 deletions(-)
> 

[...]

>  static phys_addr_t __pgd_pgtable_alloc(struct mm_struct *mm, gfp_t gfp,
> -				       enum pgtable_type pgtable_type)
> +				       enum pgtable_level pgtable_level)
>  {
>  	/* Page is zeroed by init_clear_pgtable() so don't duplicate effort. */
>  	struct ptdesc *ptdesc = pagetable_alloc(gfp & ~__GFP_ZERO, 0);
> @@ -539,40 +539,42 @@ static phys_addr_t __pgd_pgtable_alloc(struct mm_struct *mm, gfp_t gfp,
>  
>  	pa = page_to_phys(ptdesc_page(ptdesc));
>  
> -	switch (pgtable_type) {
> -	case TABLE_PTE:
> +	switch (pgtable_level) {
> +	case PGTABLE_LEVEL_PTE:
>  		BUG_ON(!pagetable_pte_ctor(mm, ptdesc));
>  		break;
> -	case TABLE_PMD:
> +	case PGTABLE_LEVEL_PMD:
>  		BUG_ON(!pagetable_pmd_ctor(mm, ptdesc));
>  		break;
> -	case TABLE_PUD:
> +	case PGTABLE_LEVEL_PUD:
>  		pagetable_pud_ctor(ptdesc);
>  		break;
> -	case TABLE_P4D:
> +	case PGTABLE_LEVEL_P4D:
>  		pagetable_p4d_ctor(ptdesc);
>  		break;
> +	default:
> +		break;

nit: I think we should either explicitly support pgd or explicitly bug/warn. Now
that the enum has PGTABLE_LEVEL_PGD it looks legit to call __pgd_pgtable_alloc()
to allocate one. But it will currently silently fail to call pagetable_pgd_ctor().

Probably simplest just to call BUG() in the default path?

With this addressed:

Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>

Thanks,
Ryan




  parent reply	other threads:[~2026-03-16 14:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 14:01 [PATCH] arm64: mm: Use generic enum pgtable_level Kevin Brodsky
2026-03-16 14:07 ` David Hildenbrand (Arm)
2026-03-16 14:22 ` Ryan Roberts [this message]
2026-03-16 14:38   ` Kevin Brodsky
2026-03-16 14:45     ` David Hildenbrand (Arm)
2026-03-17 12:47       ` Kevin Brodsky
2026-03-17 15:10         ` Ryan Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=415ea4a5-e729-4fe5-b95d-29fcca8f7dbd@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=david@kernel.org \
    --cc=kevin.brodsky@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox