From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] Maybe avoid a IPI between the cpu cores Date: Tue, 4 Dec 2012 13:20:35 +0200 Message-ID: <20121204112035.GG19514@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Alex Williamson To: yi li Return-path: Received: from mx1.redhat.com ([209.132.183.28]:6089 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837Ab2LDLUq (ORCPT ); Tue, 4 Dec 2012 06:20:46 -0500 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Dec 04, 2012 at 11:08:41AM +0800, yi li wrote: > The cpu inject the interrupt to vcpu which vcpu->cpu is the same as it. > And it maybe avoid a IPI between the cpu core. > How often this happens in your testing? Regardless we cannot disable preemption while iterating over all vcpus. Low latency people will kill us. > Signed-off-by: Yi Li > > --- linux/virt/kvm/irq_comm.c 2012-12-04 10:14:57.711024619 +0800 > +++ linux/virt/kvm/irq_comm.c 2012-12-04 11:01:27.728859597 +0800 > @@ -64,9 +64,10 @@ inline static bool kvm_is_dm_lowest_prio > int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, > struct kvm_lapic_irq *irq) > { > - int i, r = -1; > + int i, cpu, r = -1; > struct kvm_vcpu *vcpu, *lowest = NULL; > > + cpu = get_cpu(); > if (irq->dest_mode == 0 && irq->dest_id == 0xff && > kvm_is_dm_lowest_prio(irq)) { > printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n"); > @@ -89,13 +90,17 @@ int kvm_irq_delivery_to_apic(struct kvm > r = 0; > r += kvm_apic_set_irq(vcpu, irq); > } else if (kvm_lapic_enabled(vcpu)) { > - if (!lowest) > + if(vcpu->cpu == cpu) { > + lowest = vcpu; > + break; > + } > + else if (!lowest) > lowest = vcpu; > else if (kvm_apic_compare_prio(vcpu, lowest) < 0) > lowest = vcpu; > } > } > - > + put_cpu(); > if (lowest) > r = kvm_apic_set_irq(lowest, irq); > > > YiLi > Thanks > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Gleb.