diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2016-07-13 05:36:35 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-07-31 21:15:08 -0400 |
commit | 8cb8140c4c93975d7db8fbfd2fd68f7a91f74a5d (patch) | |
tree | 9772d850ef4dae0b2119863db857129ddc6a3b57 /arch/powerpc | |
parent | e2985fd9b8de51a24fa290e06c9376a03f9a8924 (diff) |
powerpc/mm/radix: Implement tlb mmu gather flush efficiently
Now that we track page size in mmu_gather, we can use address based
tlbie format when doing a tlb_flush(). We don't do this if we are
invalidating the full address space.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/book3s/64/tlbflush-radix.h | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/tlb-radix.c | 59 |
2 files changed, 60 insertions, 1 deletions
diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h index 00703e7e4c94..7ee9a195fa9c 100644 --- a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h | |||
@@ -10,6 +10,8 @@ static inline int mmu_get_ap(int psize) | |||
10 | return mmu_psize_defs[psize].ap; | 10 | return mmu_psize_defs[psize].ap; |
11 | } | 11 | } |
12 | 12 | ||
13 | extern void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start, | ||
14 | unsigned long end, int psize); | ||
13 | extern void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start, | 15 | extern void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start, |
14 | unsigned long end); | 16 | unsigned long end); |
15 | extern void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end); | 17 | extern void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end); |
diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c index e1f22700fb16..6de05c59b375 100644 --- a/arch/powerpc/mm/tlb-radix.c +++ b/arch/powerpc/mm/tlb-radix.c | |||
@@ -299,8 +299,65 @@ static int radix_get_mmu_psize(int page_size) | |||
299 | 299 | ||
300 | void radix__tlb_flush(struct mmu_gather *tlb) | 300 | void radix__tlb_flush(struct mmu_gather *tlb) |
301 | { | 301 | { |
302 | int psize = 0; | ||
302 | struct mm_struct *mm = tlb->mm; | 303 | struct mm_struct *mm = tlb->mm; |
303 | radix__flush_tlb_mm(mm); | 304 | int page_size = tlb->page_size; |
305 | |||
306 | psize = radix_get_mmu_psize(page_size); | ||
307 | /* | ||
308 | * if page size is not something we understand, do a full mm flush | ||
309 | */ | ||
310 | if (psize != -1 && !tlb->fullmm && !tlb->need_flush_all) | ||
311 | radix__flush_tlb_range_psize(mm, tlb->start, tlb->end, psize); | ||
312 | else | ||
313 | radix__flush_tlb_mm(mm); | ||
314 | } | ||
315 | |||
316 | #define TLB_FLUSH_ALL -1UL | ||
317 | /* | ||
318 | * Number of pages above which we will do a bcast tlbie. Just a | ||
319 | * number at this point copied from x86 | ||
320 | */ | ||
321 | static unsigned long tlb_single_page_flush_ceiling __read_mostly = 33; | ||
322 | |||
323 | void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start, | ||
324 | unsigned long end, int psize) | ||
325 | { | ||
326 | unsigned long pid; | ||
327 | unsigned long addr; | ||
328 | int local = mm_is_core_local(mm); | ||
329 | unsigned long ap = mmu_get_ap(psize); | ||
330 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); | ||
331 | unsigned long page_size = 1UL << mmu_psize_defs[psize].shift; | ||
332 | |||
333 | |||
334 | preempt_disable(); | ||
335 | pid = mm ? mm->context.id : 0; | ||
336 | if (unlikely(pid == MMU_NO_CONTEXT)) | ||
337 | goto err_out; | ||
338 | |||
339 | if (end == TLB_FLUSH_ALL || | ||
340 | (end - start) > tlb_single_page_flush_ceiling * page_size) { | ||
341 | if (local) | ||
342 | _tlbiel_pid(pid, RIC_FLUSH_TLB); | ||
343 | else | ||
344 | _tlbie_pid(pid, RIC_FLUSH_TLB); | ||
345 | goto err_out; | ||
346 | } | ||
347 | for (addr = start; addr < end; addr += page_size) { | ||
348 | |||
349 | if (local) | ||
350 | _tlbiel_va(addr, pid, ap, RIC_FLUSH_TLB); | ||
351 | else { | ||
352 | if (lock_tlbie) | ||
353 | raw_spin_lock(&native_tlbie_lock); | ||
354 | _tlbie_va(addr, pid, ap, RIC_FLUSH_TLB); | ||
355 | if (lock_tlbie) | ||
356 | raw_spin_unlock(&native_tlbie_lock); | ||
357 | } | ||
358 | } | ||
359 | err_out: | ||
360 | preempt_enable(); | ||
304 | } | 361 | } |
305 | 362 | ||
306 | void radix__flush_tlb_lpid_va(unsigned long lpid, unsigned long gpa, | 363 | void radix__flush_tlb_lpid_va(unsigned long lpid, unsigned long gpa, |