arm64/mm: Drop SECTION_[SHIFT|SIZE|MASK]
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
@@ -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
@@ -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
@@ -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
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.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
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@@ -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_SHIFTarch/arm64/include/asm/pgtable-hwdef.h +0
-7@@ -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
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
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
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
The clean-up looks good to me:
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