Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752247AbbLVHNi (ORCPT ); Tue, 22 Dec 2015 02:13:38 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:35069 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbbLVHNh (ORCPT ); Tue, 22 Dec 2015 02:13:37 -0500 Subject: Re: [PATCH v2 1/2] KVM: x86: Use vector-hashing to deliver lowest-priority interrupts To: "Wu, Feng" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" References: <1450229853-3886-1-git-send-email-feng.wu@intel.com> <1450229853-3886-2-git-send-email-feng.wu@intel.com> <567759F2.5080809@gmail.com> <56775E9A.5030108@gmail.com> <5678F268.5070801@gmail.com> Cc: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Jiang Liu (jiang.liu@linux.intel.com)" From: Yang Zhang Message-ID: <5678F81C.5050309@gmail.com> Date: Tue, 22 Dec 2015 15:13:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3606 Lines: 98 On 2015/12/22 14:59, Wu, Feng wrote: > > >> -----Original Message----- >> From: Yang Zhang [mailto:yang.zhang.wz@gmail.com] >> Sent: Tuesday, December 22, 2015 2:49 PM >> To: Wu, Feng ; pbonzini@redhat.com; >> rkrcmar@redhat.com >> Cc: kvm@vger.kernel.org; linux-kernel@vger.kernel.org; Jiang Liu >> (jiang.liu@linux.intel.com) >> 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 >>>>>>> --- >>>>>>> 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 >>>> *src, >>>>>>> struct kvm_lapic_irq *irq, int *r, unsigned long >> *dest_map) >>>>>>> { >>>>>>> @@ -731,17 +747,38 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm >>>>>> *kvm, struct kvm_lapic *src, >>>>>>> dst = map->logical_map[cid]; >>>>>>> >>>>>>> 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, >>>>>> dst[l]->vcpu) < 0) >>>>>>> - l = i; >>>>>>> + 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] >>>>>> && !kvm_lapic_enabled(dst[i]->vcpu)) { >>>>>> >>>>>> 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? >> >> Lapic can be disable by hw or sw. Here we only need to check the hw is >> enough which is already covered while injecting the interrupt into >> guest. I remember we(Glab, Macelo and me) have discussed it several ago, >> but i cannot find the mail thread. > > But if the lapic is disabled by software, we cannot still inject interrupts to > it, can we? Yes, We cannot inject the normal interrupt. But this already covered by current logic and add a check here seems meaningless. Conversely, it may do bad thing.. -- best regards yang -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/