KVM: X86: Reduce the overhead when lapic_timer_advance is disabled

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/9c48d517ce6da398b8cff0603b75b366759023c4
Commit:     9c48d517ce6da398b8cff0603b75b366759023c4
Parent:     74c55931c71352317ae0f5736ee9e4ca07ba4238
Refname:    refs/heads/master
Author:     Wanpeng Li <[email protected]>
AuthorDate: Fri Dec 1 00:15:10 2017 -0800
Committer:  Paolo Bonzini <[email protected]>
CommitDate: Thu Dec 14 09:26:48 2017 +0100

    KVM: X86: Reduce the overhead when lapic_timer_advance is disabled
    
    When I run ebizzy in a 32 vCPUs guest on a 32 pCPUs Xeon box, I can observe
    ~8000 kvm_wait_lapic_expire CurAvg/s through kvm_stat tool even if the advance
    tscdeadline hrtimer expiration is disabled. Each call to wait_lapic_expire()
    will consume ~70 cycles when a timer fires since apic_timer_expire() will
    set expired_tscdeadline and then wait_lapic_expire() will do some caculation
    before bailing out. So total ~175us per second is lost on this 3.2Ghz machine.
    This patch reduces the overhead by skipping the function wait_lapic_expire()
    when lapic_timer_advance is disabled.
    
    Cc: Paolo Bonzini <[email protected]>
    Cc: Radim Krčmář <[email protected]>
    Signed-off-by: Wanpeng Li <[email protected]>
    Signed-off-by: Paolo Bonzini <[email protected]>
---
 arch/x86/kvm/x86.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7ea9a57b0684..54d66f238e20 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7018,7 +7018,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 	}
 
 	trace_kvm_entry(vcpu->vcpu_id);
-	wait_lapic_expire(vcpu);
+	if (lapic_timer_advance_ns)
+		wait_lapic_expire(vcpu);
 	guest_enter_irqoff();
 
 	if (unlikely(vcpu->arch.switch_db_regs)) {
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.