From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR. Date: Sun, 05 Aug 2012 17:35:21 +0300 Message-ID: <501E84A9.8040803@redhat.com> References: <1344171513-4659-1-git-send-email-gleb@redhat.com> <1344171513-4659-6-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, mtosatti@redhat.com To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4653 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754513Ab2HEOfY (ORCPT ); Sun, 5 Aug 2012 10:35:24 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q75EZNCp025043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 5 Aug 2012 10:35:23 -0400 In-Reply-To: <1344171513-4659-6-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/05/2012 03:58 PM, Gleb Natapov wrote: > Usually all APICs are HW enabled so the check can be optimized out. > > Signed-off-by: Gleb Natapov > --- > arch/x86/kvm/lapic.c | 29 ++++++++++++++++++++++++++++- > arch/x86/kvm/lapic.h | 1 + > arch/x86/kvm/x86.c | 1 + > 3 files changed, 30 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index c3f14fe..1aa5528 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > #include "kvm_cache_regs.h" > #include "irq.h" > #include "trace.h" > @@ -117,9 +118,13 @@ static inline int __apic_test_and_clear_vector(int vec, void *bitmap) > return __test_and_clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec)); > } > > +struct static_key_deferred apic_hw_disabled __read_mostly; On top of file please. Add all_ to the name to make it clear we're talking about all apics. > + > static inline int apic_hw_enabled(struct kvm_lapic *apic) > { > - return (apic)->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE; > + if (static_key_false(&apic_hw_disabled.key)) > + return apic->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE; Hm, for the test to be readable, it needs to be if (static_key_false(&all_apics_hw_enabled)) -- error compiling committee.c: too many arguments to function