split sparc64 tlb batch from mmu_gather
This patch is another pre-requisite to the mmu_gather changes. sparc64 does it's own implementation which also tracks vaddrs. This splits it to a separate structure that is kept per-cpu and make it use the generic mmu_gather.
Signed-off-by Benjamin Herrenschmidt <[email protected]>
---
arch/sparc64/mm/tlb.c +25 -18
@@ -19,35 +19,38 @@/* Heavily inspired by the ppc64 code. */ -DEFINE_PER_CPU(struct mmu_gather, mmu_gathers) = { 0, }; +DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); +DEFINE_PER_CPU(struct tlb_batch, tlb_batch); -void flush_tlb_pending (void ) +void __flush_tlb_pending (struct tlb_batch *mp) { -struct mmu_gather *mp = &__get_cpu_var (mmu_gathers); - -preempt_disable (); - -if (mp->tlb_nr) { +if (mp->nr) {flush_tsb_user (mp);if (CTX_VALID (mp->mm->context)) {#ifdef CONFIG_SMP -smp_flush_tlb_pending (mp->mm, mp->tlb_nr, +smp_flush_tlb_pending (mp->mm, mp->nr, &mp->vaddrs[0 ]);#else -__flush_tlb_pending (CTX_HWBITS (mp->mm->context), - mp->tlb_nr, &mp->vaddrs[0 ]); +local_flush_tlb_pending (CTX_HWBITS (mp->mm->context), + mp->nr, &mp->vaddrs[0 ]);#endif } - mp->tlb_nr =0 ; + mp->nr =0 ; } +} + +void flush_tlb_pending (void ) +{ +struct tlb_batch *mp = &get_cpu_var (tlb_batch); -preempt_enable (); +__flush_tlb_pending (mp); +put_cpu_var (tlb_batch); }void tlb_batch_add (struct mm_struct *mm,unsigned long vaddr,pte_t *ptep,pte_t orig) { -struct mmu_gather *mp = &__get_cpu_var (mmu_gathers); +struct tlb_batch *mp;unsigned long nr; vaddr &=PAGE_MASK ;
@@ -79,13 +82,17 @@ void tlb_batch_add(struct mm_struct *mm, no_cache_flush: -if (mp->fullmm) +if (test_bit (MMF_DEAD , &mm->flags))return ; - nr = mp->tlb_nr; +/* we are called with enough spinlocks held to make +* preempt disable useless here +*/ + mp = &__get_cpu_var (tlb_batch); + nr = mp->nr;if (unlikely (nr !=0 && mm != mp->mm)) { -flush_tlb_pending (); +__flush_tlb_pending (mp); nr =0 ; }
@@ -93,7 +100,7 @@ no_cache_flush: mp->mm = mm; mp->vaddrs[nr] = vaddr; - mp->tlb_nr = ++nr; + mp->nr = ++nr;if (nr >=TLB_BATCH_NR ) -flush_tlb_pending (); +__flush_tlb_pending (mp); }
arch/sparc64/mm/tsb.c +3 -3
@@ -47,11 +47,11 @@ void flush_tsb_kernel_range(unsigned lon } } -static void __flush_tsb_one (struct mmu_gather *mp,unsigned long hash_shift,unsigned long tsb,unsigned long nentries) +static void __flush_tsb_one (struct tlb_batch *mp,unsigned long hash_shift,unsigned long tsb,unsigned long nentries) {unsigned long i; -for (i =0 ; i < mp->tlb_nr; i++) { +for (i =0 ; i < mp->nr; i++) {unsigned long v = mp->vaddrs[i];unsigned long tag, ent, hash;
@@ -65,7 +65,7 @@ static void __flush_tsb_one(struct mmu_g } } -void flush_tsb_user (struct mmu_gather *mp) +void flush_tsb_user (struct tlb_batch *mp) {struct mm_struct *mm = mp->mm;unsigned long nentries, base, flags;
arch/sparc64/mm/ultra.S +6 -6
@@ -52,8 +52,8 @@ __flush_tlb_mm: /* 18 insns */ nop .align 32 - .globl __flush_tlb_pending -__flush_tlb_pending: /* 26 insns */ + .globl local_flush_tlb_pending +local_flush_tlb_pending: /* 26 insns */ /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */ rdpr %pstate, %g7 sllx %o1, 3, %o1
@@ -346,8 +346,8 @@ cheetah_patch_cachetlbops: call tlb_patch_one mov 19, %o2 - sethi %hi(__flush_tlb_pending), %o0 - or %o0, %lo(__flush_tlb_pending), %o0 + sethi %hi(local_flush_tlb_pending), %o0 + or %o0, %lo(local_flush_tlb_pending), %o0 sethi %hi(__cheetah_flush_tlb_pending), %o1 or %o1, %lo(__cheetah_flush_tlb_pending), %o1 call tlb_patch_one
@@ -699,8 +699,8 @@ hypervisor_patch_cachetlbops: call tlb_patch_one mov 10, %o2 - sethi %hi(__flush_tlb_pending), %o0 - or %o0, %lo(__flush_tlb_pending), %o0 + sethi %hi(local_flush_tlb_pending), %o0 + or %o0, %lo(local_flush_tlb_pending), %o0 sethi %hi(__hypervisor_flush_tlb_pending), %o1 or %o1, %lo(__hypervisor_flush_tlb_pending), %o1 call tlb_patch_one
include/asm-sparc64/tlb.h +21 -74
122 lines not on this page · raw message
include/asm-sparc64/tlbflush.h +2 -2
@@ -5,9 +5,9 @@#include <asm/mmu_context.h> /* TSB flush operations. */ -struct mmu_gather ; +struct tlb_batch ;extern void flush_tsb_kernel_range (unsigned long start,unsigned long end); -extern void flush_tsb_user (struct mmu_gather *mp); +extern void flush_tsb_user (struct tlb_batch *mp);/* TLB flush operations. */
arch/sparc64/kernel/smp.c +1 -1
@@ -1142,7 +1142,7 @@ void smp_flush_tlb_pending(struct mm_str ctx, nr, (unsigned long ) vaddrs, mm->cpu_vm_mask); -__flush_tlb_pending (ctx, nr, vaddrs); +local_flush_tlb_pending (ctx, nr, vaddrs);put_cpu (); }
include/asm-sparc64/system.h +1 -1
@@ -151,7 +151,7 @@ do { if (test_thread_flag(TIF_PERFCTR))current_thread_info ()->kernel_cntd0 += (unsigned int )(__tmp);\current_thread_info ()->kernel_cntd1 += ((__tmp) >>32 ); \ } \ -flush_tlb_pending (); \ +check_flush_tlb_pending (); \save_and_clear_fpu (); \/* If you are tempted to conditionalize the following */ \/* so that ASI is only written if it changes, think again. */ \
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>