From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [RFC PATCH 2/2] Cache msi irq destination. Date: Mon, 13 Aug 2012 12:32:44 +0300 Message-ID: <5028C9BC.9060905@redhat.com> References: <1344849408-2697-1-git-send-email-gleb@redhat.com> <1344849408-2697-3-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, mst@redhat.com To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:64659 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826Ab2HMJct (ORCPT ); Mon, 13 Aug 2012 05:32:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7D9WnW6020423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Aug 2012 05:32:49 -0400 In-Reply-To: <1344849408-2697-3-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/13/2012 12:16 PM, Gleb Natapov wrote: > Signed-off-by: Gleb Natapov > > -int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, > +int kvm_irq_delivery_to_apic(struct kvm_kernel_irq_routing_entry *e, > + struct kvm *kvm, struct kvm_lapic *src, > struct kvm_lapic_irq *irq) Would be nicer to put e at the end, and explain that it is optional. > { > - int i, r = -1; > - struct kvm_vcpu *vcpu, *lowest = NULL; > + int i, r = -1, c = 0; > + struct kvm_vcpu *vcpu, *cache = NULL, *lowest = NULL; > > if (irq->dest_mode == 0 && irq->dest_id == 0xff && > kvm_is_dm_lowest_prio(irq)) > @@ -82,6 +83,8 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, > if (!kvm_is_dm_lowest_prio(irq)) { > if (r < 0) > r = 0; > + c++; > + cache = vcpu; > r += kvm_apic_set_irq(vcpu, irq); > } else if (kvm_lapic_enabled(vcpu)) { > if (!lowest) > @@ -93,6 +96,8 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, > > if (lowest) > r = kvm_apic_set_irq(lowest, irq); > + else if (e && c == 1) > + e->vcpu = cache; /* cache it */ > > return r; > } > @@ -118,7 +123,9 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, > irq.shorthand = 0; > > /* TODO Deal with RH bit of MSI message address */ > - return kvm_irq_delivery_to_apic(kvm, NULL, &irq); > + if (e->vcpu) > + return kvm_apic_set_irq(e->vcpu, &irq); > + return kvm_irq_delivery_to_apic(e, kvm, NULL, &irq); > } > > int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi) > @@ -131,6 +138,7 @@ int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi) > route.msi.address_lo = msi->address_lo; > route.msi.address_hi = msi->address_hi; > route.msi.data = msi->data; > + route.vcpu = NULL; > > return kvm_set_msi(&route, kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 1); > } > Missing cache invalidate on apicid write? Otherwise nice and simple. -- error compiling committee.c: too many arguments to function