Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753491AbdLLOAt (ORCPT ); Tue, 12 Dec 2017 09:00:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57744 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753298AbdLLOAo (ORCPT ); Tue, 12 Dec 2017 09:00:44 -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: <4cda5e55-6dbb-44bb-b4c1-ab196313a61c@redhat.com> Date: Tue, 12 Dec 2017 15:00:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.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.28]); Tue, 12 Dec 2017 14:00:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1326 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(-) > > 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)) { > Queued, thanks. Paolo