Re: [PATCH RESEND v2 12/21] mm/pgtable: redefine PGTABLE_LEVEL enum with ascend order from PGD
From: Yeoreum Yun
Date: Thu Nov 26 2026 - 09:31:10 EST
On Thu, Nov 26, 2026 at 03:19:13PM +0100, David Hildenbrand (Arm) wrote:
> On 11/24/26 19:52, Yeoreum Yun wrote:
> > On Tue, Nov 24, 2026 at 07:05:38PM +0200, Mike Rapoport wrote:
> >> On Mon, Nov 02, 2026 at 11:21:25AM +0000, Yeoreum Yun wrote:
> >>> The PGTABLE_LEVEL enum values appear to be ordered in the opposite direction
> >>> from their intended usage.
> >>>
> >>> Intuitively, higher page table levels should have smaller enum values,
> >>> but PTE is currently assigned 0.
> >>
> >> That's not what x86 thinks :)
> >> They even expose it in /proc/vmstat with smaller numbers meaning lower levels
> >>
> >> $ grep direct_map /proc/vmstat
> >> direct_map_level2_splits 152
> >> direct_map_level3_splits 4
> >> direct_map_level2_collapses 0
> >> direct_map_level3_collapses 0
> >>
> >> Just an observation, I don't mind either order.
> >
> > Right. I made this change because a depth-based scheme seems more intuitive.
> >
> > As you pointed out, though, the x86 specification uses smaller
> > numbers (0) for lower levels (pte), so I think we can leave the
> > x86-specific direct_map_* entries as they are.
>
> patch #14 depends on this, no?
Interestingly, x86 documentation numbers the PGD level as 4 or 5,
whereas helpers such as effective_prot_pgd() use 0 for PGD.
Anyway, this follows the usage and semantics of effective_prot_pXd(),
rather than architecture-specific level numbering, which varies across
architectures.
And yes, patch #14 depends on this, although changing the condition to
level != PGD_LEVEL would remove that dependency.
--
Sincerely,
Yeoreum Yun