Skip to contentSkip to conversation

powerpc/book3s64/hash/4k: 4k supports only 16TB linear mapping

PATCH Applied Aneesh Kumar K.V 4 participants 6 messages Sep 17, 2019 – Oct 9, 2019 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 powerpc/book3s64/hash/4k: 4k supports only 16TB linear mapping

With commit: 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in the same 0xc range"), we now split the 64TB address range into 4 contexts each of 16TB. That implies we can do only 16TB linear mapping. Make sure we don't add physical memory above 16TB if that is present in the system.

Fixes 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in thesame 0xc range")
---
 arch/powerpc/include/asm/book3s/64/mmu.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +6 -2
index bb3deb76c951..86cce8189240 100644
@@ -35,12 +35,16 @@ extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
  * memory requirements with large number of sections.
  * 51 bits is the max physical real address on POWER9
  */
-#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME) &&  \
-	defined(CONFIG_PPC_64K_PAGES)
+
+#if defined(CONFIG_PPC_64K_PAGES)
+#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME)
 #define MAX_PHYSMEM_BITS 51
 #else
 #define MAX_PHYSMEM_BITS 46
 #endif
+#else /* CONFIG_PPC_64K_PAGES */
+#define MAX_PHYSMEM_BITS 44
+#endif
 
 /* 64-bit classic hash table MMU */
 #include <asm/book3s/64/mmu-hash.h>
Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/3 powerpc/64/mm: implement page mapping percpu first chunk allocator

Implement page mapping percpu first chunk allocator as a fallback to the embedding allocator. With 4K hash translation we limit our page table range to 64TB and commit: 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in the same 0xc range") moved all kernel mapping to that 64TB range. In-order to support sparse memory layout we need to increase our linear mapping space and reduce other mappings.

With such a layout percpu embedded first chunk allocator will fail because of small vmalloc range. Add a fallback to page mapping percpu first chunk allocator for such failures.

---
 arch/powerpc/Kconfig           |  5 ++-
 arch/powerpc/kernel/setup_64.c | 59 ++++++++++++++++++++++++++++++++--
 2 files changed, 61 insertions(+), 3 deletions(-)
arch/powerpc/Kconfig +4 -1
index 6a7c797fa9d2..69d29e3486f8 100644
@@ -63,7 +63,10 @@ config HAVE_SETUP_PER_CPU_AREA
 	def_bool PPC64
 
 config NEED_PER_CPU_EMBED_FIRST_CHUNK
-	def_bool PPC64
+	def_bool y if PPC64
+
+config NEED_PER_CPU_PAGE_FIRST_CHUNK
+	def_bool y if PPC64
 
 config NR_IRQS
 	int "Number of virtual interrupt numbers"
arch/powerpc/kernel/setup_64.c +57 -2

84 lines not on this page · raw message

Signature · 1 line
2.21.0
#2 lore raw

PATCH 3/3 powerpc/book3s64/hash/4K: Update the kernel mapping with 4K page size config.

In reply to Aneesh Kumar K.V

This patch updates the kernel mapping such that we now start supporting upto 61TB of memory with 4K. The kernel mapping now looks like below:

vmalloc start     = 0xc0003d0000000000
IO start          = 0xc0003e0000000000
vmemmap start     = 0xc0003f0000000000
---
 arch/powerpc/include/asm/book3s/64/hash-4k.h | 13 ++++++-------
 arch/powerpc/include/asm/book3s/64/mmu.h     |  8 ++------
 2 files changed, 8 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/book3s/64/hash-4k.h +6 -7
index 8fd8599c9395..d56a2a2ae14a 100644
@@ -13,20 +13,19 @@
  */
 #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
+ * Our page table limit us to 64TB. For 64TB physical memory, we only need 64GB
+ * of vmemmap space. To better support sparse memory layout, we use 61TB
+ * linear map range, 1TB of vmalloc, 1TB of I/O and 1TB of vmememmap.
  */
+#define REGION_SHIFT		(40)
 #define H_KERN_MAP_SIZE		(ASM_CONST(1) << REGION_SHIFT)
 
 /*
- * Define the address range of the kernel non-linear virtual area
- * 16TB
+ * Define the address range of the kernel non-linear virtual area (61TB)
  */
-#define H_KERN_VIRT_START	ASM_CONST(0xc000100000000000)
+#define H_KERN_VIRT_START	ASM_CONST(0xc0003d0000000000)
 
 #ifndef __ASSEMBLY__
 #define H_PTE_TABLE_SIZE	(sizeof(pte_t) << H_PTE_INDEX_SIZE)
arch/powerpc/include/asm/book3s/64/mmu.h +2 -6
index 86cce8189240..bb3deb76c951 100644
@@ -35,16 +35,12 @@ extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
  * memory requirements with large number of sections.
  * 51 bits is the max physical real address on POWER9
  */
-
-#if defined(CONFIG_PPC_64K_PAGES)
-#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME)
+#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME) &&  \
+	defined(CONFIG_PPC_64K_PAGES)
 #define MAX_PHYSMEM_BITS 51
 #else
 #define MAX_PHYSMEM_BITS 46
 #endif
-#else /* CONFIG_PPC_64K_PAGES */
-#define MAX_PHYSMEM_BITS 44
-#endif
 
 /* 64-bit classic hash table MMU */
 #include <asm/book3s/64/mmu-hash.h>
Signature · 1 line
2.21.0
#3 lore raw
In reply to Aneesh Kumar K.V
Quoted 8 lines · Aneesh Kumar K.V

With commit: 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in the same 0xc range"), we now split the 64TB address range into 4 contexts each of 16TB. That implies we can do only 16TB linear mapping. Make sure we don't add physical memory above 16TB if that is present in the system.

Fixes 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in thesame 0xc range")

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/e422bd3330e5bc5cd76b063d9fc3a21cd06d9957

cheers

#4 lore raw
In reply to Aneesh Kumar K.V

Hello,

Quoted 17 lines · Aneesh Kumar K.V

With commit: 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in the same 0xc range"), we now split the 64TB address range into 4 contexts each of 16TB. That implies we can do only 16TB linear mapping. Make sure we don't add physical memory above 16TB if that is present in the system.

Fixes 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in thesame 0xc range")
---
 arch/powerpc/include/asm/book3s/64/mmu.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +0 -0
index bb3deb76c951..86cce8189240 100644

arch/powerpc/include/asm/book3s/64/mmu.h extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT]; · line 40

Quoted 8 lines
arch/powerpc/include/asm/book3s/64/mmu.h +3 -2
@@ -35,12 +35,16 @@ extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
  * memory requirements with large number of sections.
  * 51 bits is the max physical real address on POWER9
  */
-#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME) &&  \
-	defined(CONFIG_PPC_64K_PAGES)
+
+#if defined(CONFIG_PPC_64K_PAGES)
+#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME)

This prevents accessing physical memory over 16TB with 4k pages and radix MMU as well. Was this intentional?

arch/powerpc/include/asm/book3s/64/mmu.h extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT]; · line 50

Quoted 11 lines
arch/powerpc/include/asm/book3s/64/mmu.h +3 -0
 #define MAX_PHYSMEM_BITS 51
 #else
 #define MAX_PHYSMEM_BITS 46
 #endif
+#else /* CONFIG_PPC_64K_PAGES */
+#define MAX_PHYSMEM_BITS 44
+#endif
 
 /* 64-bit classic hash table MMU */
 #include <asm/book3s/64/mmu-hash.h>

Cheers,
Samuel

#5 lore raw
Quoted 15 lines · Samuel Holland

Hello,

Quoted 12 lines · Aneesh Kumar K.V

With commit: 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in the same 0xc range"), we now split the 64TB address range into 4 contexts each of 16TB. That implies we can do only 16TB linear mapping. Make sure we don't add physical memory above 16TB if that is present in the system.

Fixes 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in thesame 0xc range")
---
 arch/powerpc/include/asm/book3s/64/mmu.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Quoted 16 lines

arch/powerpc/include/asm/book3s/64/mmu.h extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT]; · line 40

Quoted 13 lines
arch/powerpc/include/asm/book3s/64/mmu.h +3 -2
index bb3deb76c951..86cce8189240 100644
@@ -35,12 +35,16 @@ extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
  * memory requirements with large number of sections.
  * 51 bits is the max physical real address on POWER9
  */
-#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME) &&  \
-	defined(CONFIG_PPC_64K_PAGES)
+
+#if defined(CONFIG_PPC_64K_PAGES)
+#if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME)

This prevents accessing physical memory over 16TB with 4k pages and radix MMU as well. Was this intentional?

No, it was meant to be a temporary fix until the rest of Aneesh's series fixed things up properly, but then there were problems with those patches so he asked me to just pick up this one.

At the moment 4K hash won't boot at all if you have too much RAM on P9, so this was meant to at least avoid that.

But breaking 4K radix is arguably worse, so I'll drop this for now.

cheers