aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2014-11-02 10:45:28 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-12-01 22:10:11 -0500
commitd557b09800dab5dd6804e5b79324069abcf0be11 (patch)
treecb28d3966042edb834d23341d9f98bdf95c1646c /arch/powerpc
parentf1581bf14bc40b4a14bf10358eac0b22173b3313 (diff)
powerpc/mm/thp: Use tlbiel if possible
If we know that user address space has never executed on other cpus we could use tlbiel. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/machdep.h2
-rw-r--r--arch/powerpc/include/asm/tlbflush.h3
-rw-r--r--arch/powerpc/mm/hash_native_64.c4
-rw-r--r--arch/powerpc/mm/hash_utils_64.c28
-rw-r--r--arch/powerpc/mm/hugepage-hash64.c2
-rw-r--r--arch/powerpc/mm/pgtable_64.c9
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c2
7 files changed, 37 insertions, 13 deletions
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 15c9150a58cc..e5c0919acca4 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -60,7 +60,7 @@ struct machdep_calls {
60 void (*hugepage_invalidate)(unsigned long vsid, 60 void (*hugepage_invalidate)(unsigned long vsid,
61 unsigned long addr, 61 unsigned long addr,
62 unsigned char *hpte_slot_array, 62 unsigned char *hpte_slot_array,
63 int psize, int ssize); 63 int psize, int ssize, int local);
64 /* special for kexec, to be called in real mode, linear mapping is 64 /* special for kexec, to be called in real mode, linear mapping is
65 * destroyed as well */ 65 * destroyed as well */
66 void (*hpte_clear_all)(void); 66 void (*hpte_clear_all)(void);
diff --git a/arch/powerpc/include/asm/tlbflush.h b/arch/powerpc/include/asm/tlbflush.h
index 19550d346fea..4d3ecd8d8929 100644
--- a/arch/powerpc/include/asm/tlbflush.h
+++ b/arch/powerpc/include/asm/tlbflush.h
@@ -128,7 +128,8 @@ extern void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize,
128 int ssize, int local); 128 int ssize, int local);
129extern void flush_hash_range(unsigned long number, int local); 129extern void flush_hash_range(unsigned long number, int local);
130extern void flush_hash_hugepage(unsigned long vsid, unsigned long addr, 130extern void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
131 pmd_t *pmdp, unsigned int psize, int ssize); 131 pmd_t *pmdp, unsigned int psize, int ssize,
132 int local);
132 133
133static inline void local_flush_tlb_mm(struct mm_struct *mm) 134static inline void local_flush_tlb_mm(struct mm_struct *mm)
134{ 135{
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 558e50bac6f7..13700911b522 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -425,7 +425,7 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn,
425static void native_hugepage_invalidate(unsigned long vsid, 425static void native_hugepage_invalidate(unsigned long vsid,
426 unsigned long addr, 426 unsigned long addr,
427 unsigned char *hpte_slot_array, 427 unsigned char *hpte_slot_array,
428 int psize, int ssize) 428 int psize, int ssize, int local)
429{ 429{
430 int i; 430 int i;
431 struct hash_pte *hptep; 431 struct hash_pte *hptep;
@@ -471,7 +471,7 @@ static void native_hugepage_invalidate(unsigned long vsid,
471 * instruction compares entry_VA in tlb with the VA specified 471 * instruction compares entry_VA in tlb with the VA specified
472 * here 472 * here
473 */ 473 */
474 tlbie(vpn, psize, actual_psize, ssize, 0); 474 tlbie(vpn, psize, actual_psize, ssize, local);
475 } 475 }
476 local_irq_restore(flags); 476 local_irq_restore(flags);
477} 477}
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 6c2076c65d7c..68211d398fdb 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -1317,7 +1317,7 @@ void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize, int ssize,
1317 1317
1318#ifdef CONFIG_TRANSPARENT_HUGEPAGE 1318#ifdef CONFIG_TRANSPARENT_HUGEPAGE
1319void flush_hash_hugepage(unsigned long vsid, unsigned long addr, 1319void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
1320 pmd_t *pmdp, unsigned int psize, int ssize) 1320 pmd_t *pmdp, unsigned int psize, int ssize, int local)
1321{ 1321{
1322 int i, max_hpte_count, valid; 1322 int i, max_hpte_count, valid;
1323 unsigned long s_addr; 1323 unsigned long s_addr;
@@ -1334,9 +1334,11 @@ void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
1334 if (!hpte_slot_array) 1334 if (!hpte_slot_array)
1335 return; 1335 return;
1336 1336
1337 if (ppc_md.hugepage_invalidate) 1337 if (ppc_md.hugepage_invalidate) {
1338 return ppc_md.hugepage_invalidate(vsid, s_addr, hpte_slot_array, 1338 ppc_md.hugepage_invalidate(vsid, s_addr, hpte_slot_array,
1339 psize, ssize); 1339 psize, ssize, local);
1340 goto tm_abort;
1341 }
1340 /* 1342 /*
1341 * No bluk hpte removal support, invalidate each entry 1343 * No bluk hpte removal support, invalidate each entry
1342 */ 1344 */
@@ -1362,8 +1364,24 @@ void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
1362 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 1364 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
1363 slot += hidx & _PTEIDX_GROUP_IX; 1365 slot += hidx & _PTEIDX_GROUP_IX;
1364 ppc_md.hpte_invalidate(slot, vpn, psize, 1366 ppc_md.hpte_invalidate(slot, vpn, psize,
1365 MMU_PAGE_16M, ssize, 0); 1367 MMU_PAGE_16M, ssize, local);
1368 }
1369tm_abort:
1370#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1371 /* Transactions are not aborted by tlbiel, only tlbie.
1372 * Without, syncing a page back to a block device w/ PIO could pick up
1373 * transactional data (bad!) so we force an abort here. Before the
1374 * sync the page will be made read-only, which will flush_hash_page.
1375 * BIG ISSUE here: if the kernel uses a page from userspace without
1376 * unmapping it first, it may see the speculated version.
1377 */
1378 if (local && cpu_has_feature(CPU_FTR_TM) &&
1379 current->thread.regs &&
1380 MSR_TM_ACTIVE(current->thread.regs->msr)) {
1381 tm_enable();
1382 tm_abort(TM_CAUSE_TLBI);
1366 } 1383 }
1384#endif
1367} 1385}
1368#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 1386#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
1369 1387
diff --git a/arch/powerpc/mm/hugepage-hash64.c b/arch/powerpc/mm/hugepage-hash64.c
index 1b3ad46a71b5..3a648cd363ae 100644
--- a/arch/powerpc/mm/hugepage-hash64.c
+++ b/arch/powerpc/mm/hugepage-hash64.c
@@ -95,7 +95,7 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
95 */ 95 */
96 if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO)) 96 if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO))
97 flush_hash_hugepage(vsid, ea, pmdp, MMU_PAGE_64K, 97 flush_hash_hugepage(vsid, ea, pmdp, MMU_PAGE_64K,
98 ssize); 98 ssize, local);
99 } 99 }
100 100
101 valid = hpte_valid(hpte_slot_array, index); 101 valid = hpte_valid(hpte_slot_array, index);
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index c175c990580e..eea9fa1f8ae7 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -739,9 +739,10 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
739void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr, 739void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
740 pmd_t *pmdp, unsigned long old_pmd) 740 pmd_t *pmdp, unsigned long old_pmd)
741{ 741{
742 int ssize; 742 int ssize, local = 0;
743 unsigned int psize; 743 unsigned int psize;
744 unsigned long vsid; 744 unsigned long vsid;
745 const struct cpumask *tmp;
745 746
746 /* get the base page size,vsid and segment size */ 747 /* get the base page size,vsid and segment size */
747#ifdef CONFIG_DEBUG_VM 748#ifdef CONFIG_DEBUG_VM
@@ -762,7 +763,11 @@ void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
762 ssize = mmu_kernel_ssize; 763 ssize = mmu_kernel_ssize;
763 } 764 }
764 765
765 return flush_hash_hugepage(vsid, addr, pmdp, psize, ssize); 766 tmp = cpumask_of(smp_processor_id());
767 if (cpumask_equal(mm_cpumask(mm), tmp))
768 local = 1;
769
770 return flush_hash_hugepage(vsid, addr, pmdp, psize, ssize, local);
766} 771}
767 772
768static pmd_t pmd_set_protbits(pmd_t pmd, pgprot_t pgprot) 773static pmd_t pmd_set_protbits(pmd_t pmd, pgprot_t pgprot)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index d214a012b026..832f221840f2 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -442,7 +442,7 @@ static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
442static void pSeries_lpar_hugepage_invalidate(unsigned long vsid, 442static void pSeries_lpar_hugepage_invalidate(unsigned long vsid,
443 unsigned long addr, 443 unsigned long addr,
444 unsigned char *hpte_slot_array, 444 unsigned char *hpte_slot_array,
445 int psize, int ssize) 445 int psize, int ssize, int local)
446{ 446{
447 int i, index = 0; 447 int i, index = 0;
448 unsigned long s_addr = addr; 448 unsigned long s_addr = addr;