Re: [RFC PATCH 2/2] Cache msi irq destination.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 13, 2012 at 12:32:44PM +0300, Avi Kivity wrote:
> On 08/13/2012 12:16 PM, Gleb Natapov wrote:
> > Signed-off-by: Gleb Natapov <gleb@xxxxxxxxxx>
> >  
> > -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.
> 
Just a prototype to see how it goes :)

> >  {
> > -	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?
> 
Yes. Need to call to kvm_set_irq_routing() in strategic places. Same for
ioapic.

> Otherwise nice and simple.
> 
> 
> -- 
> error compiling committee.c: too many arguments to function

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux