Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/fsl-book3e-64: Use paca for hugetlb TLB1 entry selection

This keeps usage coordinated for hugetlb and indirect entries, which
should make entry selection more predictable and probably improve overall
performance when mixing the two.

Signed-off-by: Scott Wood <scottwood@freescale.com>

+41 -10
+41 -10
arch/powerpc/mm/hugetlbpage-book3e.c
··· 8 8 #include <linux/mm.h> 9 9 #include <linux/hugetlb.h> 10 10 11 + #ifdef CONFIG_PPC_FSL_BOOK3E 12 + #ifdef CONFIG_PPC64 13 + static inline int tlb1_next(void) 14 + { 15 + struct paca_struct *paca = get_paca(); 16 + struct tlb_core_data *tcd; 17 + int this, next; 18 + 19 + tcd = paca->tcd_ptr; 20 + this = tcd->esel_next; 21 + 22 + next = this + 1; 23 + if (next >= tcd->esel_max) 24 + next = tcd->esel_first; 25 + 26 + tcd->esel_next = next; 27 + return this; 28 + } 29 + #else 30 + static inline int tlb1_next(void) 31 + { 32 + int index, ncams; 33 + 34 + ncams = mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY; 35 + 36 + index = __get_cpu_var(next_tlbcam_idx); 37 + 38 + /* Just round-robin the entries and wrap when we hit the end */ 39 + if (unlikely(index == ncams - 1)) 40 + __get_cpu_var(next_tlbcam_idx) = tlbcam_index; 41 + else 42 + __get_cpu_var(next_tlbcam_idx)++; 43 + 44 + return index; 45 + } 46 + #endif /* !PPC64 */ 47 + #endif /* FSL */ 48 + 11 49 static inline int mmu_get_tsize(int psize) 12 50 { 13 51 return mmu_psize_defs[psize].enc; ··· 85 47 struct mm_struct *mm; 86 48 87 49 #ifdef CONFIG_PPC_FSL_BOOK3E 88 - int index, ncams; 50 + int index; 89 51 #endif 90 52 91 53 if (unlikely(is_kernel_addr(ea))) ··· 115 77 } 116 78 117 79 #ifdef CONFIG_PPC_FSL_BOOK3E 118 - ncams = mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY; 119 - 120 80 /* We have to use the CAM(TLB1) on FSL parts for hugepages */ 121 - index = __get_cpu_var(next_tlbcam_idx); 81 + index = tlb1_next(); 122 82 mtspr(SPRN_MAS0, MAS0_ESEL(index) | MAS0_TLBSEL(1)); 123 - 124 - /* Just round-robin the entries and wrap when we hit the end */ 125 - if (unlikely(index == ncams - 1)) 126 - __get_cpu_var(next_tlbcam_idx) = tlbcam_index; 127 - else 128 - __get_cpu_var(next_tlbcam_idx)++; 129 83 #endif 84 + 130 85 mas1 = MAS1_VALID | MAS1_TID(mm->context.id) | MAS1_TSIZE(tsize); 131 86 mas2 = ea & ~((1UL << shift) - 1); 132 87 mas2 |= (pte_val(pte) >> PTE_WIMGE_SHIFT) & MAS2_WIMGE_MASK;