Kouya Shimura
2009-Jul-10 06:34 UTC
[Xen-devel] [PATCH V2] passthrough: deliver IRQs even if VCPU#0 is halted
Essentially nothing is changed from my previous patch.
Diffs are:
- split hvm_dirq_assist() for readability
- a little bit efficent for MP race condition
The attached patch is not so readable.
I''ll show the following handmade diff for human.
====================================================================== void
hvm_dirq_assist(struct vcpu *v)
{
struct domain *d = v->domain;
struct hvm_irq_dpci *hvm_irq_dpci = d->arch.hvm_domain.irq.dpci;
- unsigned int irq;
+ unsigned int irq, i, dirq_mask_size;
+ unsigned long mask;
- if ( !iommu_enabled || (v->vcpu_id != 0) || (hvm_irq_dpci == NULL) )
+ if ( !iommu_enabled || (hvm_irq_dpci == NULL) )
return;
- for ( irq = find_first_bit(hvm_irq_dpci->dirq_mask, d->nr_pirqs);
- irq < d->nr_pirqs;
- irq = find_next_bit(hvm_irq_dpci->dirq_mask, d->nr_pirqs, irq +
1) )
- {
- if ( !test_and_clear_bit(irq, hvm_irq_dpci->dirq_mask) )
- continue;
-
- __hvm_dirq_assist(d, hvm_irq_dpci, irq);
- }
+ dirq_mask_size = BITS_TO_LONGS(d->nr_pirqs);
+ for (i = 0; i < dirq_mask_size; i++)
+ mask = xchg(&hvm_irq_dpci->dirq_mask[i], 0L);
+
+ while ( mask != 0 )
+ {
+ irq = find_first_set_bit(mask);
+ mask &= ~(1UL << irq);
+ irq += (i * BITS_PER_LONG);
+ if ( irq < d->nr_pirqs )
+ __hvm_dirq_assist(d, hvm_irq_dpci, irq);
+ }
+ }
}
======================================================================
while d->nr_pirqs<=64, dirq_mask_size is 1 (d->nr_pirqs is normally
32).
Then the efficiency is not so worse than comparing v->vcpu_id != 0.
Thanks,
Kouya
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Keir Fraser
2009-Jul-10 08:20 UTC
[Xen-devel] Re: [PATCH V2] passthrough: deliver IRQs even if VCPU#0 is halted
On 10/07/2009 07:34, "Kouya Shimura" <kouya@jp.fujitsu.com> wrote:> Essentially nothing is changed from my previous patch. > Diffs are: > - split hvm_dirq_assist() for readability > - a little bit efficent for MP race conditionJust target the i8259_target, and don''t bother with the MP efficiency changes. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Kouya Shimura
2009-Jul-10 09:27 UTC
[Xen-devel] Re: [PATCH V2] passthrough: deliver IRQs even if VCPU#0 is halted
Keir Fraser writes:> Just target the i8259_target, and don''t bother with the MP efficiency > changes.Sure. Attached. kdump works fine with this patch. I was a little bit worried about i8259_target pointing the halted VCPU#0. Thanks, Kouya Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2009-Jul-10 09:38 UTC
[Xen-devel] Re: [PATCH V2] passthrough: deliver IRQs even if VCPU#0 is halted
On 10/07/2009 10:27, "Kouya Shimura" <kouya@jp.fujitsu.com> wrote:> Keir Fraser writes: >> Just target the i8259_target, and don''t bother with the MP efficiency >> changes. > > Sure. Attached. kdump works fine with this patch. > I was a little bit worried about i8259_target pointing the halted VCPU#0.In your specific case it won''t when it matters (kdump kernel comes up, reprograms IO-APIC which fixes i8259_target, then brings up PCI layer). Really I think some of that dirq assist stuff should be put in a tasklet. But let''s not worry about that now, and just patch it up this way. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel