Skip to contentSkip to conversation

arm64/mm: Drop SECTION_[SHIFT|SIZE|MASK]

PATCH Applied Anshuman Khandual 4 participants 4 messages Jun 14, 2021 – Jun 15, 2021 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64/mm: Drop SECTION_[SHIFT|SIZE|MASK]

SECTION_[SHIFT|SIZE|MASK] are essentially PMD_[SHIFT|SIZE|MASK]. But these create confusion being similar to generic sparsemem memory sections, which are derived from SECTION_SIZE_BITS. Section references have always implied PMD level block mapping. Instead just use all PMD level macros which would make it explicit and also remove confusion with sparsmem memory sections.

---
This applies on v5.13-rc6.

 arch/arm64/include/asm/kernel-pgtable.h | 4 ++--
 arch/arm64/include/asm/pgtable-hwdef.h  | 7 -------
 arch/arm64/mm/mmu.c                     | 2 +-
 3 files changed, 3 insertions(+), 10 deletions(-)
arch/arm64/include/asm/kernel-pgtable.h +2 -2
index d44df9d62fc9..88b8d681ad91 100644
@@ -91,8 +91,8 @@
 
 /* Initial memory map size */
 #if ARM64_SWAPPER_USES_SECTION_MAPS
-#define SWAPPER_BLOCK_SHIFT	SECTION_SHIFT
-#define SWAPPER_BLOCK_SIZE	SECTION_SIZE
+#define SWAPPER_BLOCK_SHIFT	PMD_SHIFT
+#define SWAPPER_BLOCK_SIZE	PMD_SIZE
 #define SWAPPER_TABLE_SHIFT	PUD_SHIFT
 #else
 #define SWAPPER_BLOCK_SHIFT	PAGE_SHIFT
arch/arm64/include/asm/pgtable-hwdef.h +0 -7
index b82575a33f8b..40085e53f573 100644
@@ -71,13 +71,6 @@
 #define PGDIR_MASK		(~(PGDIR_SIZE-1))
 #define PTRS_PER_PGD		(1 << (VA_BITS - PGDIR_SHIFT))
 
-/*
- * Section address mask and size definitions.
- */
-#define SECTION_SHIFT		PMD_SHIFT
-#define SECTION_SIZE		(_AC(1, UL) << SECTION_SHIFT)
-#define SECTION_MASK		(~(SECTION_SIZE-1))
-
 /*
  * Contiguous page definitions.
  */
arch/arm64/mm/mmu.c +1 -1
index 89b66ef43a0f..380771610dd2 100644
@@ -228,7 +228,7 @@ static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end,
 		next = pmd_addr_end(addr, end);
 
 		/* try section mapping first */
-		if (((addr | next | phys) & ~SECTION_MASK) == 0 &&
+		if (((addr | next | phys) & ~PMD_MASK) == 0 &&
 		    (flags & NO_BLOCK_MAPPINGS) == 0) {
 			pmd_set_huge(pmdp, phys, prot);
 
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Anshuman Khandual

SECTION_[SHIFT|SIZE|MASK] are essentially PMD_[SHIFT|SIZE|MASK]. But these create confusion being similar to generic sparsemem memory sections, which are derived from SECTION_SIZE_BITS. Section references have always implied PMD level block mapping. Instead just use all PMD level macros which would make it explicit and also remove confusion with sparsmem memory sections.

Quoted 8 lines

---
This applies on v5.13-rc6.

  arch/arm64/include/asm/kernel-pgtable.h | 4 ++--
  arch/arm64/include/asm/pgtable-hwdef.h  | 7 -------
  arch/arm64/mm/mmu.c                     | 2 +-
  3 files changed, 3 insertions(+), 10 deletions(-)

It does introduce confusion to sparsemem section. The changes look good to me:

Quoted 39 lines
arch/arm64/include/asm/kernel-pgtable.h +2 -2
index d44df9d62fc9..88b8d681ad91 100644
@@ -91,8 +91,8 @@
 
  /* Initial memory map size */
  #if ARM64_SWAPPER_USES_SECTION_MAPS
-#define SWAPPER_BLOCK_SHIFT	SECTION_SHIFT
-#define SWAPPER_BLOCK_SIZE	SECTION_SIZE
+#define SWAPPER_BLOCK_SHIFT	PMD_SHIFT
+#define SWAPPER_BLOCK_SIZE	PMD_SIZE
  #define SWAPPER_TABLE_SHIFT	PUD_SHIFT
  #else
  #define SWAPPER_BLOCK_SHIFT	PAGE_SHIFT
arch/arm64/include/asm/pgtable-hwdef.h +0 -7
index b82575a33f8b..40085e53f573 100644
@@ -71,13 +71,6 @@
  #define PGDIR_MASK		(~(PGDIR_SIZE-1))
  #define PTRS_PER_PGD		(1 << (VA_BITS - PGDIR_SHIFT))
 
-/*
- * Section address mask and size definitions.
- */
-#define SECTION_SHIFT		PMD_SHIFT
-#define SECTION_SIZE		(_AC(1, UL) << SECTION_SHIFT)
-#define SECTION_MASK		(~(SECTION_SIZE-1))
-
  /*
   * Contiguous page definitions.
   */
arch/arm64/mm/mmu.c +0 -0
index 89b66ef43a0f..380771610dd2 100644

arch/arm64/mm/mmu.c static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end, · line 234

Quoted 8 lines
arch/arm64/mm/mmu.c +1 -1
@@ -228,7 +228,7 @@ static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end,
  		next = pmd_addr_end(addr, end);
 
  		/* try section mapping first */
-		if (((addr | next | phys) & ~SECTION_MASK) == 0 &&
+		if (((addr | next | phys) & ~PMD_MASK) == 0 &&
  		    (flags & NO_BLOCK_MAPPINGS) == 0) {
  			pmd_set_huge(pmdp, phys, prot);
 

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Anshuman Khandual
Quoted 6 lines · Anshuman Khandual

SECTION_[SHIFT|SIZE|MASK] are essentially PMD_[SHIFT|SIZE|MASK]. But these create confusion being similar to generic sparsemem memory sections, which are derived from SECTION_SIZE_BITS. Section references have always implied PMD level block mapping. Instead just use all PMD level macros which would make it explicit and also remove confusion with sparsmem memory sections.

Quoted 6 lines

The clean-up looks good to me:

maintainer Applied
#3 lore raw
In reply to Anshuman Khandual
Quoted 5 lines · Anshuman Khandual

SECTION_[SHIFT|SIZE|MASK] are essentially PMD_[SHIFT|SIZE|MASK]. But these create confusion being similar to generic sparsemem memory sections, which are derived from SECTION_SIZE_BITS. Section references have always implied PMD level block mapping. Instead just use all PMD level macros which would make it explicit and also remove confusion with sparsmem memory sections.

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

[1/1] arm64/mm: Drop SECTION_[SHIFT|SIZE|MASK]

      https://git.kernel.org/arm64/c/4aaa87ab3d2d

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev