Re: [PATCH] arm64/mm: Rename PGD_SIZE as PGD_TABLE_SIZE

From: Anshuman Khandual

Date: Thu Jul 16 2026 - 00:39:49 EST




On 15/07/26 6:26 PM, Will Deacon wrote:
> On Tue, Jul 14, 2026 at 10:00:50AM +0530, Anshuman Khandual wrote:
>> PXD_SIZE represents the virtual address range size covered by a single page
>> table entry on a given page table level. On arm64 PGD entry address span is
>> represented with PGDIR_XXX macros instead while PGD_SIZE has been referring
>> to size of the PGD table itself. So PGD_SIZE has been some what confusing.
>>
>> Rename PGD_SIZE as PGD_TABLE_SIZE making it explicit that it represents PGD
>> table size rather than virtual address range covered by a single PGD entry.
>> While here, also move PGD_TABLE_SIZE inside pgtable-hwdef.h header.
>>
>> No functional change.
>>
>> Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
>> Cc: Will Deacon <will@xxxxxxxxxx>
>> Cc: Ryan Roberts <ryan.roberts@xxxxxxx>
>> Cc: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
>> Cc: linux-kernel@xxxxxxxxxxxxxxx
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
>> ---
>> arch/arm64/include/asm/pgalloc.h | 2 --
>> arch/arm64/include/asm/pgtable-hwdef.h | 1 +
>> arch/arm64/mm/mmu.c | 2 +-
>> arch/arm64/mm/pgd.c | 6 +++---
>> 4 files changed, 5 insertions(+), 6 deletions(-)
>
> I'm not disagreeing that we have an inconsistency here, but does this
> patch series help in any meaningful way? Firstly, folks are probably
> pretty used to the current (inconsistent) terminology by now and,
> secondly, I think the main problem is that we have both PGDIR* and PGD*
> based constants, so adding a PGD_TABLE_SIZE just makes things more
> confusing. Worse, this exists even in core code:
>
> include/linux/pgtable.h:
> #define pgd_index(a) (((a) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
>
> so I would argue that, if you wanted to repaint all of this, that would
> be the place to start, not by making the arm64 even weirder.
>
> Personally, though, I'd leave it all alone because I not a big fan of
> this sort of churn in isolation.

Agreed that PGDIR_SHIFT/SIZE is the true source of this inconsistency
deviating from all other pgtable level's macros expressing an address
range. But this above PGD_SIZE based confusion is specific (but then
well contained) inside arm and arm64 platforms.

Changing PGDIR_[SHIFT|SIZE] on all platforms to PGD_[SHIFT|SIZE] and
then converting arm and arm64 platform's PGD_SIZE as PGDIR_SIZE might
be a better solution. But as suggested will just drop this for now.