Possible fix for spurious interrupts
PATCH 1/1 Possible fix for spurious interrupts
Here is a patch that appears to fix the spurious interrupt problems for me. This is inspired by Jan's observation that the IO-APIC mask/unmask that we do for ISR processing seems to cause corruption of other routing entries. So the fix here is to do the same as native Linux -- do not mask/unmask, but instead send EOI after doing ISR processing.
To confirm this really was the problem I modified native Linux to do the same as Xen currently does (mask before ISR processing; unmask after). I then got lots of spurious USB interrupts even on native Linux! :-(
Please test... I'll put it in xen-unstable tomorrow if there are no complaints and it will be a strong candidate for the next 3.0.2 release too.
-- Keir
xen/arch/x86/io_apic.c +16 -18
@@ -190,16 +190,16 @@__modify_IO_APIC_irq (irq,0 ,0x00010000 ); } -/* trigger = 0 */ -static void __edge_IO_APIC_irq (unsigned int irq) -{ -__modify_IO_APIC_irq (irq,0 ,0x00008000 ); -} - -/* trigger = 1 */ -static void __level_IO_APIC_irq (unsigned int irq) -{ -__modify_IO_APIC_irq (irq,0x00008000 ,0 ); +/* mask = 1, trigger = 0 */ +static void __mask_and_edge_IO_APIC_irq (unsigned int irq) +{ +__modify_IO_APIC_irq (irq,0x00010000 ,0x00008000 ); +} + +/* mask = 0, trigger = 1 */ +static void __unmask_and_level_IO_APIC_irq (unsigned int irq) +{ +__modify_IO_APIC_irq (irq,0x00008000 ,0x00010000 ); }static void mask_IO_APIC_irq (unsigned int irq)
@@ -1323,10 +1323,13 @@static void mask_and_ack_level_ioapic_irq (unsigned int irq) { +} + +static void end_level_ioapic_irq (unsigned int irq) +{unsigned long v;int i; -mask_IO_APIC_irq (irq);/* * It appears there is an erratum which affects at least version 0x11 * of I/O APIC (that's the 82093AA and cores integrated into various
@@ -1355,15 +1358,10 @@if (!(v & (1 << (i &0x1f )))) {atomic_inc (&irq_mis_count);spin_lock (&ioapic_lock); -__edge_IO_APIC_irq (irq); -__level_IO_APIC_irq (irq); +__mask_and_edge_IO_APIC_irq (irq); +__unmask_and_level_IO_APIC_irq (irq);spin_unlock (&ioapic_lock); } -} - -static void end_level_ioapic_irq (unsigned int irq) -{ -unmask_IO_APIC_irq (irq); }static unsigned int startup_edge_ioapic_vector (unsigned int vector)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi,
Quoted 6 lines · Keir Fraser
To confirm this really was the problem I modified native Linux to do the same as Xen currently does (mask before ISR processing; unmask after). I then got lots of spurious USB interrupts even on native Linux! :-(
Please test...
Looks like it cures it completely for me. I've got the same box running the same load that used to send irq16 through the roof, and it's currently pegged at:
16: 0 0 0 0 Phys-irq uhci_hcd:usb2, uhci_hcd:usb5
Thanks!
I'm moving back to the UK shortly so won't personally be able to double-check this again from the final xen-unstable tree, btw.
--Stephen
Quoted 7 lines · Stephen C. Tweedie
Looks like it cures it completely for me. I've got the same box running the same load that used to send irq16 through the roof, and it's currently pegged at:
16: 0 0 0 0 Phys-irq uhci_hcd:usb2, uhci_hcd:usb5Thanks!
Actually, it seems the patch doesn't entirely work for multi-processor domain 0 as the wrong local APIC is sometimes prodded to do the EOI cycle. This was partially hidden by the fact that IRQ ffinity is also currently broken in our Linux tree (we need to call move_irq() in a few choice places). I'll get a complete fix for all this stuff into xen-unstable today. Probably the meat of the patch should wait a while before going into the -testing tree, but we'll want to get something in there before 3.0.2-3.
-- Keir
I think you guys are running into the same problem that FreeBSD ran into on some Intel motherboards more than a year ago.
This explanation seems to make the most sense.
http://thread.gmane.org/gmane.os.freebsd.current/67490/focus=67490
Because the problem happened on FreeBSD (which masks ioapic RTEs to implement interrupt threads) and not on Linux, it was hard to get attention from the hardware guys back then. I had suspected Xen would run into it sooner or later.
-Arun
Quoted 11 lines · Arun Sharma
I think you guys are running into the same problem that FreeBSD ran into on some Intel motherboards more than a year ago.
This explanation seems to make the most sense.
http://thread.gmane.org/gmane.os.freebsd.current/67490/focus=67490
Because the problem happened on FreeBSD (which masks ioapic RTEs to implement interrupt threads) and not on Linux, it was hard to get attention from the hardware guys back then. I had suspected Xen would run into it sooner or later.
Thanks Arun, this is very informative although unfortunately not very helpful. Matt Dillon's suggested alternatives to masking do not really work as they all cause spurious interrupts. Do you know if they ever found a good fix, or do they live with the problem?
I'd not heard of boot interrupt mode before, but it sounds like many chipsets cannot disable it and, even when it can be disabled, the method is chipset specific. The Intel legacy INTx model is so unbelievably crap. At least source-vectored interrupts are becoming more common.
Anyway, this the current status of my workaround for Xen:
1. I added a new ioapic ack method which delays EOI until after ISR
processing in the driver domain. This mode is enabled by default but can be disabled with 'ioapic_ack=old' as a Xen boot parameter.
2. The code to safely manage deferred EOI is quite complicated and has
some weaknesses:
* Must EOI on the CPU that received the interrupt
* Must EOI in 'reverse' order when interrupts have nested
* Un-EOIed interrupts block other guest-bound interrupts which
happen to have lower priority
* Right now, disable_irq() in a driver domain may potentially lock
up all interrupt sources as it may prevent EOI ever happening (until enable_irq() or the interrupt is unbound from the domain)
* All Xen-bound interrupts have strictly higher priority than any
guest-bound IO-APIC interrupt. This should avoid deadlock issues.
Really it's a messy solution. I think having both old and new ack methods makes sense, but I'm not sure how we will end up picking which to use automatically. Maybe using the old method is best, and let users pick the new one if they see spurious interrupt problems. Or maybe the problems with the new method are mostly theoretical and we should use that by default. Or maybe we should have a DMI table to pick between them. I'm not sure.
Another question is whether to put this in 3.0.2. I think it definitely needs more testing before that, but it might not make sense to do so at all as the patch is quite invasive.
-- Keir
Quoted 2 lines · Keir Fraser
Thanks Arun, this is very informative although unfortunately not very helpful. Matt Dillon's suggested alternatives to masking do not really work as they all cause spurious interrupts. Do you know if they ever found a good fix, or do they live with the problem?
They never found a good fix. How they live with the problem is explained in this status report under "e1000 driver improvements":
http://www.freebsd.org/news/status/report-oct-2005-dec-2005.html
-Arun