From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH] kvm: optimize ISR lookups Date: Tue, 22 May 2012 00:51:27 +0300 Message-ID: <20120521215127.GH17031@redhat.com> References: <20120521163727.GA13337@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Avi Kivity , Marcelo Tosatti , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org To: Thomas Gleixner Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Mon, May 21, 2012 at 11:04:25PM +0200, Thomas Gleixner wrote: > > @@ -242,6 +262,25 @@ static inline void apic_clear_irr(int vec, struct kvm_lapic *apic) > > apic->irr_pending = true; > > } > > > > +static inline void apic_set_isr(int vec, struct kvm_lapic *apic) > > +{ > > + if (!__apic_test_and_set_vector(vec, apic->regs + APIC_ISR)) > > + ++apic->isr_count; > > + ASSERT(apic->isr_count > MAX_APIC_VECTOR); > > I'm really curious what you observed when defining DEBUG in that file. > > Clearly you never did. Sorry :( Yes clearly silly, thanks for pointing this out. > > + if (likely(apic->isr_count == 1)) > > + apic->isr_cache = vec; > > + else > > + apic->isr_cache = -1; > > +} > > + > > +static inline void apic_clear_isr(int vec, struct kvm_lapic *apic) > > +{ > > + if (__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR)) > > + --apic->isr_count; > > + ASSERT(apic->isr_count < 0); > > Ditto. > > > result = find_highest_vector(apic->regs + APIC_ISR); > > ASSERT(result == -1 || result >= 16); > > And obviously none of the folks who added this gem bothered to define > DEBUG either. > > So please instead of working around horrid design decisions and adding > more mess to the existing one, can we please cleanup the stuff first > and then decide whether it's worth to add the extra magic? > > Thanks, > > tglx