Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64/mm: Compute PTRS_PER_[PMD|PUD] independently of PTRS_PER_PTE

Possible page table entries (or pointers) on non-zero page table levels are
dependent on a single page size i.e PAGE_SIZE and size required for each
individual page table entry i.e 8 bytes. PTRS_PER_[PMD|PUD] as such are not
related to PTRS_PER_PTE in any manner, as being implied currently. So lets
just make this very explicit and compute these macros independently.

Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Link: https://lore.kernel.org/r/20220408041009.1259701-1-anshuman.khandual@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Anshuman Khandual and committed by
Catalin Marinas
2a2848e7 b2d229d4

+2 -2
+2 -2
arch/arm64/include/asm/pgtable-hwdef.h
··· 49 49 #define PMD_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(2) 50 50 #define PMD_SIZE (_AC(1, UL) << PMD_SHIFT) 51 51 #define PMD_MASK (~(PMD_SIZE-1)) 52 - #define PTRS_PER_PMD PTRS_PER_PTE 52 + #define PTRS_PER_PMD (1 << (PAGE_SHIFT - 3)) 53 53 #endif 54 54 55 55 /* ··· 59 59 #define PUD_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(1) 60 60 #define PUD_SIZE (_AC(1, UL) << PUD_SHIFT) 61 61 #define PUD_MASK (~(PUD_SIZE-1)) 62 - #define PTRS_PER_PUD PTRS_PER_PTE 62 + #define PTRS_PER_PUD (1 << (PAGE_SHIFT - 3)) 63 63 #endif 64 64 65 65 /*