diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> | 2019-04-17 14:59:17 +0200 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2019-04-21 15:12:40 +0200 |
commit | 1c946c1b7f2ba40bc9b521219ad34e5da3fc3088 (patch) | |
tree | 17e48a3b636c8479cd97c42cc33a5770f5e788ec /arch/powerpc/include | |
parent | powerpc/mm: Drop the unnecessary region check (diff) | |
download | linux-1c946c1b7f2ba40bc9b521219ad34e5da3fc3088.tar.xz linux-1c946c1b7f2ba40bc9b521219ad34e5da3fc3088.zip |
powerpc/mm/hash: Simplify the region id calculation.
This reduces multiple comparisons in get_region_id to a bit shift operation.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r-- | arch/powerpc/include/asm/book3s/64/hash-4k.h | 4 | ||||
-rw-r--r-- | arch/powerpc/include/asm/book3s/64/hash-64k.h | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/book3s/64/hash.h | 31 | ||||
-rw-r--r-- | arch/powerpc/include/asm/book3s/64/mmu-hash.h | 2 |
4 files changed, 20 insertions, 18 deletions
diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h index 4c9dfd625461..8fd8599c9395 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h @@ -13,12 +13,14 @@ */ #define MAX_EA_BITS_PER_CONTEXT 46 +#define REGION_SHIFT (MAX_EA_BITS_PER_CONTEXT - 2) + /* * Our page table limit us to 64TB. Hence for the kernel mapping, * each MAP area is limited to 16 TB. * The four map areas are: linear mapping, vmap, IO and vmemmap */ -#define H_KERN_MAP_SIZE (ASM_CONST(1) << (MAX_EA_BITS_PER_CONTEXT - 2)) +#define H_KERN_MAP_SIZE (ASM_CONST(1) << REGION_SHIFT) /* * Define the address range of the kernel non-linear virtual area diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h index 0d0191cda050..d1d9177d9ebd 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h @@ -13,6 +13,7 @@ * is handled in the hotpath. */ #define MAX_EA_BITS_PER_CONTEXT 49 +#define REGION_SHIFT MAX_EA_BITS_PER_CONTEXT /* * We use one context for each MAP area. diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h index 76741a221910..7faa3d7214c0 100644 --- a/arch/powerpc/include/asm/book3s/64/hash.h +++ b/arch/powerpc/include/asm/book3s/64/hash.h @@ -83,26 +83,26 @@ #define H_VMEMMAP_SIZE H_KERN_MAP_SIZE #define H_VMEMMAP_END (H_VMEMMAP_START + H_VMEMMAP_SIZE) +#define NON_LINEAR_REGION_ID(ea) ((((unsigned long)ea - H_KERN_VIRT_START) >> REGION_SHIFT) + 2) + /* * Region IDs */ -#define USER_REGION_ID 1 -#define KERNEL_REGION_ID 2 -#define VMALLOC_REGION_ID 3 -#define IO_REGION_ID 4 -#define VMEMMAP_REGION_ID 5 +#define USER_REGION_ID 0 +#define KERNEL_REGION_ID 1 +#define VMALLOC_REGION_ID NON_LINEAR_REGION_ID(H_VMALLOC_START) +#define IO_REGION_ID NON_LINEAR_REGION_ID(H_KERN_IO_START) +#define VMEMMAP_REGION_ID NON_LINEAR_REGION_ID(H_VMEMMAP_START) /* * Defines the address of the vmemap area, in its own region on * hash table CPUs. */ - #ifdef CONFIG_PPC_MM_SLICES #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN #endif /* CONFIG_PPC_MM_SLICES */ - /* PTEIDX nibble */ #define _PTEIDX_SECONDARY 0x8 #define _PTEIDX_GROUP_IX 0x7 @@ -113,22 +113,21 @@ #ifndef __ASSEMBLY__ static inline int get_region_id(unsigned long ea) { + int region_id; int id = (ea >> 60UL); if (id == 0) return USER_REGION_ID; - VM_BUG_ON(id != 0xc); - VM_BUG_ON(ea >= H_VMEMMAP_END); + if (ea < H_KERN_VIRT_START) + return KERNEL_REGION_ID; - if (ea >= H_VMEMMAP_START) - return VMEMMAP_REGION_ID; - else if (ea >= H_KERN_IO_START) - return IO_REGION_ID; - else if (ea >= H_VMALLOC_START) - return VMALLOC_REGION_ID; + VM_BUG_ON(id != 0xc); + BUILD_BUG_ON(NON_LINEAR_REGION_ID(H_VMALLOC_START) != 2); - return KERNEL_REGION_ID; + region_id = NON_LINEAR_REGION_ID(ea); + VM_BUG_ON(region_id > VMEMMAP_REGION_ID); + return region_id; } #define hash__pmd_bad(pmd) (pmd_val(pmd) & H_PMD_BAD_BITS) diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h index 8a30bf189f10..9a9adbeef070 100644 --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h @@ -823,7 +823,7 @@ static inline unsigned long get_kernel_context(unsigned long ea) */ ctx = 1 + ((ea & EA_MASK) >> MAX_EA_BITS_PER_CONTEXT); } else - ctx = region_id + MAX_KERNEL_CTX_CNT - 2; + ctx = region_id + MAX_KERNEL_CTX_CNT - 1; return ctx; } |