powerpc: thp: Use tlbiel wherever possible
PATCH 1/1 powerpc: thp: Use tlbiel wherever possible
If we know that user address space has never executed on other cpus we could use tlbiel.
--- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/mm/hash_native_64.c | 4 ++-- arch/powerpc/mm/hugepage-hash64.c | 10 ++++++---- arch/powerpc/mm/pgtable_64.c | 11 ++++++++--- arch/powerpc/platforms/pseries/lpar.c | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/machdep.h +1 -1
@@ -60,7 +60,7 @@ struct machdep_calls {void (*hugepage_invalidate)(unsigned long vsid,unsigned long addr,unsigned char *hpte_slot_array, -int psize,int ssize); +int psize,int ssize,int local);/* special for kexec, to be called in real mode, linear mapping is * destroyed as well */ void (*hpte_clear_all)(void );
arch/powerpc/mm/hash_native_64.c +2 -2
@@ -415,7 +415,7 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn,static void native_hugepage_invalidate (unsigned long vsid,unsigned long addr,unsigned char *hpte_slot_array, -int psize,int ssize) +int psize,int ssize,int local) {int i;struct hash_pte *hptep;
@@ -461,7 +461,7 @@ static void native_hugepage_invalidate(unsigned long vsid,* instruction compares entry_VA in tlb with the VA specified * here */ -tlbie (vpn, psize, actual_psize, ssize,0 ); +tlbie (vpn, psize, actual_psize, ssize, local); }local_irq_restore (flags); }
arch/powerpc/mm/hugepage-hash64.c +6 -4
@@ -19,7 +19,8 @@#include <asm/machdep.h> static void invalidate_old_hpte (unsigned long vsid,unsigned long addr, -pmd_t *pmdp,unsigned int psize,int ssize) +pmd_t *pmdp,unsigned int psize, +int ssize,int local) {int i, max_hpte_count, valid;unsigned long s_addr;
@@ -38,7 +39,7 @@ static void invalidate_old_hpte(unsigned long vsid, unsigned long addr,if (ppc_md.hugepage_invalidate)return ppc_md.hugepage_invalidate (vsid, s_addr, hpte_slot_array, - psize, ssize); + psize, ssize, local);/* * No bluk hpte removal support, invalidate each entry */
@@ -64,7 +65,7 @@ static void invalidate_old_hpte(unsigned long vsid, unsigned long addr, slot = (hash & htab_hash_mask) *HPTES_PER_GROUP ; slot += hidx & _PTEIDX_GROUP_IX; ppc_md.hpte_invalidate (slot, vpn, psize, -MMU_PAGE_16M , ssize,0 ); +MMU_PAGE_16M , ssize, local); } }
@@ -145,7 +146,8 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,* hash page table entries. */ if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO)) -invalidate_old_hpte (vsid, ea, pmdp,MMU_PAGE_64K , ssize); +invalidate_old_hpte (vsid, ea, pmdp,MMU_PAGE_64K , + ssize, local); } valid =hpte_valid (hpte_slot_array, index);
arch/powerpc/mm/pgtable_64.c +8 -3
@@ -731,10 +731,11 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,void hpte_do_hugepage_flush (struct mm_struct *mm,unsigned long addr,pmd_t *pmdp,unsigned long old_pmd) { -int ssize, i; +int ssize, i, local =0 ;unsigned long s_addr;int max_hpte_count;unsigned int psize, valid; +const struct cpumask *tmp;unsigned char *hpte_slot_array;unsigned long hidx, vpn, vsid, hash, shift, slot;
@@ -770,10 +771,14 @@ void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr, ssize = mmu_kernel_ssize; } + tmp =cpumask_of (smp_processor_id ()); +if (cpumask_equal (mm_cpumask (mm), tmp)) + local =1 ; +if (ppc_md.hugepage_invalidate)return ppc_md.hugepage_invalidate (vsid, s_addr, hpte_slot_array, - psize, ssize); + psize, ssize, local);/* * No bluk hpte removal support, invalidate each entry */
@@ -799,7 +804,7 @@ void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr, slot = (hash & htab_hash_mask) *HPTES_PER_GROUP ; slot += hidx & _PTEIDX_GROUP_IX; ppc_md.hpte_invalidate (slot, vpn, psize, -MMU_PAGE_16M , ssize,0 ); +MMU_PAGE_16M , ssize, local); } }
arch/powerpc/platforms/pseries/lpar.c +1 -1
@@ -433,7 +433,7 @@ static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,static void pSeries_lpar_hugepage_invalidate (unsigned long vsid,unsigned long addr,unsigned char *hpte_slot_array, -int psize,int ssize) +int psize,int ssize,int local) {int i, index =0 ;unsigned long s_addr = addr;
Signature · 1 line
1.9.1
Quoted 4 lines · Aneesh Kumar K.V
If we know that user address space has never executed on other cpus we could use tlbiel.
Signed-off-by Aneesh Kumar K.V <[email protected]>
Now checking against flush_hash_page, I am wondering whether I need to handle transcational memory in case of tlbiel ? Michael, can you let me know if this is needed ?
-aneesh
Quoted 10 lines · Aneesh Kumar K.V
Quoted 4 lines · Aneesh Kumar K.V
If we know that user address space has never executed on other cpus we could use tlbiel.
Signed-off-by Aneesh Kumar K.V <[email protected]>Now checking against
flush_hash_page, I am wondering whether I need to handle transcational memory in case of tlbiel ? Michael, can you let me know if this is needed ?
Also, beware that we have code that sets "tlbiel" in the page definition array to 0 on all but 4k and 64k pages...
Cheers,
Ben.
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Aneesh Kumar K.V
Quoted 3 lines · Aneesh Kumar K.V
If we know that user address space has never executed on other cpus we could use tlbiel.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Aneesh Kumar K.V <[email protected]>Now checking against
flush_hash_page, I am wondering whether I need to handle transcational memory in case of tlbiel ? Michael, can you let me know if this is needed ?Also, beware that we have code that sets "tlbiel" in the page definition array to 0 on all but 4k and 64k pages...
Ok we use base page size to determine whether we can use tlbiel or not.
static inline void tlbie(unsigned long vpn, int psize, int apsize,
int ssize, int local)
{
....
if (use_local) use_local = mmu_psize_defs[psize].tlbiel;
With that we should be ok, because we are using 4k and 64k base page size and we have
/*
* We don't know for sure what's up with tlbiel, so
* for now we only set it for 4K and 64K pages */
if (base_idx == MMU_PAGE_4K || base_idx == MMU_PAGE_64K)
def->tlbiel = 1; else def->tlbiel = 0;
-aneesh
Quoted 8 lines · Aneesh Kumar K.V
"Aneesh Kumar K.V" <[email protected]> writes:
=20Quoted 4 lines
If we know that user address space has never executed on other cpus we could use tlbiel.
Signed-off-by Aneesh Kumar K.V <[email protected]>=20
Now checking againstflush_hash_page, I am wondering whether I need to ha=
ndle
Quoted 2 lines
transcational memory in case of tlbiel ? Michael, can you let me know if this is needed ?
Yeah, you do need to add something. =20
local tlbie won't abort the transaction (broadcast will abort), so you need to do a explicit tabort if there is an active transaction, to make sure the transaction is doomed.
Mikey