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

Anshuman Khandual posted 1 patch 4 years, 2 months ago
arch/arm64/include/asm/pgtable-hwdef.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] arm64/mm: Compute PTRS_PER_[PMD|PUD] independently of PTRS_PER_PTE
Posted by Anshuman Khandual 4 years, 2 months ago
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: Catalin Marinas <catalin.marinas@arm.com>
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>
---
This applies on v5.18-rc1

 arch/arm64/include/asm/pgtable-hwdef.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 66671ff05183..dd3d12bce07b 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -49,7 +49,7 @@
 #define PMD_SHIFT		ARM64_HW_PGTABLE_LEVEL_SHIFT(2)
 #define PMD_SIZE		(_AC(1, UL) << PMD_SHIFT)
 #define PMD_MASK		(~(PMD_SIZE-1))
-#define PTRS_PER_PMD		PTRS_PER_PTE
+#define PTRS_PER_PMD		(1 << (PAGE_SHIFT - 3))
 #endif
 
 /*
@@ -59,7 +59,7 @@
 #define PUD_SHIFT		ARM64_HW_PGTABLE_LEVEL_SHIFT(1)
 #define PUD_SIZE		(_AC(1, UL) << PUD_SHIFT)
 #define PUD_MASK		(~(PUD_SIZE-1))
-#define PTRS_PER_PUD		PTRS_PER_PTE
+#define PTRS_PER_PUD		(1 << (PAGE_SHIFT - 3))
 #endif
 
 /*
-- 
2.20.1
Re: [PATCH] arm64/mm: Compute PTRS_PER_[PMD|PUD] independently of PTRS_PER_PTE
Posted by Catalin Marinas 4 years, 1 month ago
On Fri, 8 Apr 2022 09:40:09 +0530, Anshuman Khandual wrote:
> 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.
> 
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64/mm: Compute PTRS_PER_[PMD|PUD] independently of PTRS_PER_PTE
      https://git.kernel.org/arm64/c/2a2848e7c2fd

-- 
Catalin
Re: [PATCH] arm64/mm: Compute PTRS_PER_[PMD|PUD] independently of PTRS_PER_PTE
Posted by Catalin Marinas 4 years, 1 month ago
On Fri, Apr 08, 2022 at 09:40:09AM +0530, Anshuman Khandual wrote:
> 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.

OTOH, we have lots of other assumptions about pmd etc. being updated
using the pte macros. Anyway, I'm fine with this.

-- 
Catalin