From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] [APIC] Optimize searching for highest IRR Date: Tue, 19 May 2009 13:09:43 +0300 Message-ID: <4A128567.8070906@redhat.com> References: <1242636246-11547-1-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx2.redhat.com ([66.187.237.31]:56083 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbZESKJo (ORCPT ); Tue, 19 May 2009 06:09:44 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4JA9jZw005499 for ; Tue, 19 May 2009 06:09:45 -0400 In-Reply-To: <1242636246-11547-1-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Gleb Natapov wrote: > Most of the time IRR is empty, so instead of scanning the whole IRR on > each VM entry keep a variable that tells us if IRR is not empty. IRR > will have to be scanned twice on each IRQ delivery, but this is much more > rare than VM entry. > > > static inline int apic_find_highest_irr(struct kvm_lapic *apic) > { > int result; > > - result = find_highest_vector(apic->regs + APIC_IRR); > + if (!apic->irr_pending) > + return -1; > smp_mb__before_clear_bit(), to prevent the cpu speculating the IRR. > + > + result = apic_search_irr(apic); > ASSERT(result == -1 || result >= 16); > > return result; > } > > +static inline void apic_clear_irr(int vec, struct kvm_lapic *apic) > +{ > + apic->irr_pending = false; > + apic_clear_vector(vec, apic->regs + APIC_IRR); > smp_rmb() > + if (apic_search_irr(apic) != -1) > + apic->irr_pending = true; > -- error compiling committee.c: too many arguments to function