Skip to content

Commit b755745

Browse files
npigginpaulusmack
authored andcommitted
KVM: PPC: Book3S HV: Lockless tlbie for HPT hcalls
tlbies to an LPAR do not have to be serialised since POWER4/PPC970, after which the MMU_FTR_LOCKLESS_TLBIE feature was introduced to avoid tlbie locking. Since commit c17b98c ("KVM: PPC: Book3S HV: Remove code for PPC970 processors"), KVM no longer supports processors that do not have this feature, so the tlbie locking can be removed completely. A sanity check for the feature is put in kvmppc_mmu_hv_init. Testing was done on a POWER9 system in HPT mode, with a -smp 32 guest in HPT mode. 32 instances of the powerpc fork benchmark from selftests were run with --fork, and the results measured. Without this patch, total throughput was about 13.5K/sec, and this is the top of the host profile: 74.52% [k] do_tlbies 2.95% [k] kvmppc_book3s_hv_page_fault 1.80% [k] calc_checksum 1.80% [k] kvmppc_vcpu_run_hv 1.49% [k] kvmppc_run_core After this patch, throughput was about 51K/sec, with this profile: 21.28% [k] do_tlbies 5.26% [k] kvmppc_run_core 4.88% [k] kvmppc_book3s_hv_page_fault 3.30% [k] _raw_spin_lock_irqsave 3.25% [k] gup_pgd_range Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent f19d1f3 commit b755745

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

arch/powerpc/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ struct kvm_arch {
269269
unsigned long host_lpcr;
270270
unsigned long sdr1;
271271
unsigned long host_sdr1;
272-
int tlbie_lock;
273272
unsigned long lpcr;
274273
unsigned long vrma_slb_v;
275274
int mmu_ready;

arch/powerpc/kvm/book3s_64_mmu_hv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ int kvmppc_mmu_hv_init(void)
272272
if (!cpu_has_feature(CPU_FTR_HVMODE))
273273
return -EINVAL;
274274

275+
if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE))
276+
return -EINVAL;
277+
275278
/* POWER7 has 10-bit LPIDs (12-bit in POWER8) */
276279
host_lpid = mfspr(SPRN_LPID);
277280
rsvd_lpid = LPID_RSVD;

arch/powerpc/kvm/book3s_hv_rm_mmu.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -435,24 +435,6 @@ static inline int is_mmio_hpte(unsigned long v, unsigned long r)
435435
(HPTE_R_KEY_HI | HPTE_R_KEY_LO));
436436
}
437437

438-
static inline int try_lock_tlbie(unsigned int *lock)
439-
{
440-
unsigned int tmp, old;
441-
unsigned int token = LOCK_TOKEN;
442-
443-
asm volatile("1:lwarx %1,0,%2\n"
444-
" cmpwi cr0,%1,0\n"
445-
" bne 2f\n"
446-
" stwcx. %3,0,%2\n"
447-
" bne- 1b\n"
448-
" isync\n"
449-
"2:"
450-
: "=&r" (tmp), "=&r" (old)
451-
: "r" (lock), "r" (token)
452-
: "cc", "memory");
453-
return old == 0;
454-
}
455-
456438
static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues,
457439
long npages, int global, bool need_sync)
458440
{
@@ -464,8 +446,6 @@ static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues,
464446
* the RS field, this is backwards-compatible with P7 and P8.
465447
*/
466448
if (global) {
467-
while (!try_lock_tlbie(&kvm->arch.tlbie_lock))
468-
cpu_relax();
469449
if (need_sync)
470450
asm volatile("ptesync" : : : "memory");
471451
for (i = 0; i < npages; ++i) {
@@ -484,7 +464,6 @@ static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues,
484464
}
485465

486466
asm volatile("eieio; tlbsync; ptesync" : : : "memory");
487-
kvm->arch.tlbie_lock = 0;
488467
} else {
489468
if (need_sync)
490469
asm volatile("ptesync" : : : "memory");

0 commit comments

Comments
 (0)