-----Original Message-----
From: linux-kernel-owner@xxxxxxxxxxxxxxx [mailto:linux-kernel-
owner@xxxxxxxxxxxxxxx] On Behalf Of Yang Zhang
Sent: Monday, December 21, 2015 10:06 AM
To: Wu, Feng <feng.wu@xxxxxxxxx>; pbonzini@xxxxxxxxxx;
rkrcmar@xxxxxxxxxx
Cc: kvm@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
Subject: Re: [PATCH v2 1/2] KVM: x86: Use vector-hashing to deliver lowest-
priority interrupts
On 2015/12/21 9:50, Wu, Feng wrote:
*src,
-----Original Message-----
From: Yang Zhang [mailto:yang.zhang.wz@xxxxxxxxx]
Sent: Monday, December 21, 2015 9:46 AM
To: Wu, Feng <feng.wu@xxxxxxxxx>; pbonzini@xxxxxxxxxx;
rkrcmar@xxxxxxxxxx
Cc: kvm@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
Subject: Re: [PATCH v2 1/2] KVM: x86: Use vector-hashing to deliver lowest-
priority interrupts
On 2015/12/16 9:37, Feng Wu wrote:
Use vector-hashing to deliver lowest-priority interrupts, As an++++++++++++++++++++++++++++++++++++++++---------
example, modern Intel CPUs in server platform use this method to
handle lowest-priority interrupts.
Signed-off-by: Feng Wu <feng.wu@xxxxxxxxx>
---
arch/x86/kvm/irq_comm.c | 27 ++++++++++++++++++-----
arch/x86/kvm/lapic.c | 57
arch/x86/kvm/lapic.h | 2 ++
arch/x86/kvm/x86.c | 9 ++++++++
arch/x86/kvm/x86.h | 1 +
5 files changed, 81 insertions(+), 15 deletions(-)
bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic
struct kvm_lapic_irq *irq, int *r, unsigned long *dest_map)*kvm, struct kvm_lapic *src,
{
@@ -731,17 +747,38 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm
dst = map->logical_map[cid];dst[l]->vcpu) < 0)
if (kvm_lowest_prio_delivery(irq)) {
- int l = -1;
- for_each_set_bit(i, &bitmap, 16) {
- if (!dst[i])
- continue;
- if (l < 0)
- l = i;
- else if (kvm_apic_compare_prio(dst[i]->vcpu,
- l = i;&& !kvm_lapic_enabled(dst[i]->vcpu)) {
+ if (!kvm_vector_hashing_enabled()) {
+ int l = -1;
+ for_each_set_bit(i, &bitmap, 16) {
+ if (!dst[i])
+ continue;
+ if (l < 0)
+ l = i;
+ else if (kvm_apic_compare_prio(dst[i]-
vcpu, dst[l]->vcpu) < 0)
+ l = i;
+ }
+ bitmap = (l >= 0) ? 1 << l : 0;
+ } else {
+ int idx = 0;
+ unsigned int dest_vcpus = 0;
+
+ for_each_set_bit(i, &bitmap, 16) {
+ if (!dst[i]
It should be or(||) not and (&&).
Oh, you are right! My negligence! Thanks for pointing this out, Yang!
btw, i think the kvm_lapic_enabled check is wrong here? Why need it here?
If the lapic is not enabled, I think we cannot recognize it as a candidate, can we?
Maybe Radim can confirm this, Radim, what is your option?
Thanks,
Feng