diff options
author | Gleb Natapov <gleb@redhat.com> | 2009-03-05 16:34:59 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-06-10 11:48:27 +0300 |
commit | e1035715ef8d3171e29f9c6aee6f40d57b3fead5 (patch) | |
tree | 1ead65420a4d1653692d0e4b66a4e4f7fcbef425 /virt | |
parent | 343f94fe4d16ec898da77720c03da9e09f8523d2 (diff) | |
download | linux-e1035715ef8d3171e29f9c6aee6f40d57b3fead5.tar.bz2 |
KVM: change the way how lowest priority vcpu is calculated
The new way does not require additional loop over vcpus to calculate
the one with lowest priority as one is chosen during delivery bitmap
construction.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/ioapic.h | 3 | ||||
-rw-r--r-- | virt/kvm/irq_comm.c | 19 |
2 files changed, 12 insertions, 10 deletions
diff --git a/virt/kvm/ioapic.h b/virt/kvm/ioapic.h index d996c7abc466..e7bc92d895ff 100644 --- a/virt/kvm/ioapic.h +++ b/virt/kvm/ioapic.h @@ -64,10 +64,9 @@ static inline struct kvm_ioapic *ioapic_irqchip(struct kvm *kvm) return kvm->arch.vioapic; } -struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector, - unsigned long *bitmap); int kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, int short_hand, int dest, int dest_mode); +int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); void kvm_ioapic_update_eoi(struct kvm *kvm, int vector, int trigger_mode); int kvm_ioapic_init(struct kvm *kvm); int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level); diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index e43701c0a5c4..f5e059b67cd4 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -47,7 +47,7 @@ void kvm_get_intr_delivery_bitmask(struct kvm *kvm, struct kvm_lapic *src, int dest_id, int dest_mode, bool low_prio, int short_hand, unsigned long *deliver_bitmask) { - int i; + int i, lowest = -1; struct kvm_vcpu *vcpu; if (dest_mode == 0 && dest_id == 0xff && low_prio) @@ -64,15 +64,18 @@ void kvm_get_intr_delivery_bitmask(struct kvm *kvm, struct kvm_lapic *src, dest_mode)) continue; - __set_bit(i, deliver_bitmask); + if (!low_prio) { + __set_bit(i, deliver_bitmask); + } else { + if (lowest < 0) + lowest = i; + if (kvm_apic_compare_prio(vcpu, kvm->vcpus[lowest]) < 0) + lowest = i; + } } - if (low_prio) { - vcpu = kvm_get_lowest_prio_vcpu(kvm, 0, deliver_bitmask); - bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS); - if (vcpu) - __set_bit(vcpu->vcpu_id, deliver_bitmask); - } + if (lowest != -1) + __set_bit(lowest, deliver_bitmask); } static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, |