kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Maybe avoid a IPI between the cpu cores
@ 2012-12-04  3:08 yi li
  2012-12-04  3:49 ` yi li
  2012-12-04 11:20 ` Gleb Natapov
  0 siblings, 2 replies; 6+ messages in thread
From: yi li @ 2012-12-04  3:08 UTC (permalink / raw)
  To: kvm; +Cc: Alex Williamson

    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.

    Signed-off-by: Yi Li <yilikernel@gmail.com>

--- 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-12-05 10:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-04  3:08 [PATCH] Maybe avoid a IPI between the cpu cores yi li
2012-12-04  3:49 ` yi li
2012-12-04 11:20 ` Gleb Natapov
2012-12-04 17:32   ` yi li
2012-12-04 17:48     ` yi li
2012-12-05 10:31     ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).