Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751776AbdLAIgC (ORCPT ); Fri, 1 Dec 2017 03:36:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50012 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751202AbdLAIgA (ORCPT ); Fri, 1 Dec 2017 03:36:00 -0500 Subject: Re: [PATCH] KVM: X86: Reduce the overhead when lapic_timer_advance is disabled To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li References: <1512116110-8355-1-git-send-email-wanpeng.li@hotmail.com> From: Paolo Bonzini Message-ID: <217b8854-a6d8-1c84-a137-8ddcf051de41@redhat.com> Date: Fri, 1 Dec 2017 09:35:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1512116110-8355-1-git-send-email-wanpeng.li@hotmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 01 Dec 2017 08:36:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1357 Lines: 36 On 01/12/2017 09:15, Wanpeng Li wrote: > 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 > Cc: Radim Krčmář > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/x86.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Paolo Bonzini Paolo > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 50c8361..d1abf13 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6994,7 +6994,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)) { >