Skip to contentSkip to conversation

sparc64: Fix physical memory management regressions with large max_phys_bits.

PATCH New David Miller 1 participant 1 message Oct 4, 2014 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 4/9 sparc64: Fix physical memory management regressions with large max_phys_bits.

If max_phys_bits needs to be > 43 (f.e. for T4 chips), things like DEBUG_PAGEALLOC stop working because the 3-level page tables only can cover up to 43 bits.

Another problem is that when we increased MAX_PHYS_ADDRESS_BITS up to 47, several statically allocated tables became enormous.

Compounding this is that we will need to support up to 49 bits of physical addressing for M7 chips.

The two tables in question are sparc64_valid_addr_bitmap and kpte_linear_bitmap.

The first holds a bitmap, with 1 bit for each 4MB chunk of physical memory, indicating whether that chunk actually exists in the machine and is valid.

The second table is a set of 2-bit values which tell how large of a mapping (4MB, 256MB, 2GB, 16GB, respectively) we can use at each 256MB chunk of ram in the system.

These tables are huge and take up an enormous amount of the BSS section of the sparc64 kernel image. Specifically, the sparc64_valid_addr_bitmap is 4MB, and the kpte_linear_bitmap is 128K.

So let's solve the space wastage and the DEBUG_PAGEALLOC problem at the same time, by using the kernel page tables (as designed) to manage this information.

We have to keep using large mappings when DEBUG_PAGEALLOC is disabled, and we do this by encoding huge PMDs and PUDs.

On a T4-2 with 256GB of ram the kernel page table takes up 16K with DEBUG_PAGEALLOC disabled and 256MB with it enabled. Furthermore, this memory is dynamically allocated at run time rather than coded statically into the kernel image.

---
 arch/sparc/include/asm/page_64.h    |   3 -
 arch/sparc/include/asm/pgtable_64.h |  55 +++--
 arch/sparc/include/asm/tsb.h        |  47 ++++-
 arch/sparc/kernel/ktlb.S            | 108 +---------
 arch/sparc/kernel/vmlinux.lds.S     |   5 -
 arch/sparc/mm/init_64.c             | 393 +++++++++++++++---------------------
 arch/sparc/mm/init_64.h             |   7 -
 7 files changed, 244 insertions(+), 374 deletions(-)
arch/sparc/include/asm/page_64.h +0 -3
index 2211a80..732ba17 100644
@@ -128,9 +128,6 @@ extern unsigned long PAGE_OFFSET;
  */
 #define MAX_PHYS_ADDRESS_BITS	47
 
-/* These two shift counts are used when indexing sparc64_valid_addr_bitmap
- * and kpte_linear_bitmap.
- */
 #define ILOG2_4MB		22
 #define ILOG2_256MB		28
 
arch/sparc/include/asm/pgtable_64.h +26 -29

104 lines not on this page · raw message

arch/sparc/include/asm/tsb.h +41 -6

65 lines not on this page · raw message

arch/sparc/kernel/ktlb.S +9 -99

134 lines not on this page · raw message

arch/sparc/kernel/vmlinux.lds.S +0 -5
index 932ff90..0bacceb 100644
@@ -122,11 +122,6 @@ SECTIONS
 		*(.swapper_4m_tsb_phys_patch)
 		__swapper_4m_tsb_phys_patch_end = .;
 	}
-	.page_offset_shift_patch : {
-		__page_offset_shift_patch = .;
-		*(.page_offset_shift_patch)
-		__page_offset_shift_patch_end = .;
-	}
 	.popc_3insn_patch : {
 		__popc_3insn_patch = .;
 		*(.popc_3insn_patch)
arch/sparc/mm/init_64.c +168 -225

513 lines not on this page · raw message

arch/sparc/mm/init_64.h +0 -7
index 0668b36..29ff73f 100644
@@ -8,15 +8,8 @@
  */
 
 #define MAX_PHYS_ADDRESS	(1UL << MAX_PHYS_ADDRESS_BITS)
-#define KPTE_BITMAP_CHUNK_SZ		(256UL * 1024UL * 1024UL)
-#define KPTE_BITMAP_BYTES	\
-	((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 4)
-#define VALID_ADDR_BITMAP_CHUNK_SZ	(4UL * 1024UL * 1024UL)
-#define VALID_ADDR_BITMAP_BYTES	\
-	((MAX_PHYS_ADDRESS / VALID_ADDR_BITMAP_CHUNK_SZ) / 8)
 
 extern unsigned long kern_linear_pte_xor[4];
-extern unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)];
 extern unsigned int sparc64_highest_unlocked_tlb_ent;
 extern unsigned long sparc64_kern_pri_context;
 extern unsigned long sparc64_kern_pri_nuc_bits;
Signature · 1 line
1.8.1.2