mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Linus Torvalds <torvalds@osdl.org>
Cc: Komuro <komurojun-mbn@nifty.com>,
	tglx@linutronix.de, Adrian Bunk <bunk@stusta.de>,
	Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	mingo@redhat.com
Subject: Re: 2.6.19-rc5: known regressions :SMP kernel can not generate ISA irq
Date: Mon, 13 Nov 2006 10:11:24 -0700	[thread overview]
Message-ID: <m13b8ns24j.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0611130742440.22714@g5.osdl.org> (Linus Torvalds's message of "Mon, 13 Nov 2006 08:02:28 -0800 (PST)")

Linus Torvalds <torvalds@osdl.org> writes:

> On Fri, 10 Nov 2006, Komuro wrote:
>> 
>> I tried the 2.6.19-rc5,  the problem still happens.
>
> Ok, that's good data, and especially:
>
>> But,
>> I remove the disable_irq_nosync() , enable_irq()
>> from the linux/drivers/net/pcmcia/axnet_cs.c
>> the interrupt is generated properly.
>
> All RIGHT. That's a very good clue. The major difference between PCI and 
> ISA irq's is that they have different trigger types (they also have 
> different polarity, but that tends to be just a small detail). In 
> particular, ISA IRQ's are edge-triggered, and PCI IRQ's are level- 
> triggered.
>
> Now, edge-triggered interrupts are a _lot_ harder to mask, because the 
> Intel APIC is an unbelievable piece of sh*t, and has the edge-detect logic 
> _before_ the mask logic, so if a edge happens _while_ the device is 
> masked, you'll never ever see the edge ever again (unmasking will not 
> cause a new edge, so you simply lost the interrupt).
>
> So when you "mask" an edge-triggered IRQ, you can't really mask it at all, 
> because if you did that, you'd lose it forever if the IRQ comes in while 
> you masked it. Instead, we're supposed to leave it active, and set a flag, 
> and IF the IRQ comes in, we just remember it, and mask it at that point 
> instead, and then on unmasking, we have to replay it by sending a 
> self-IPI.
>
> Maybe that part got broken by some of the IRQ changes by Eric. 

Hmm.  The other possibility is that this is a genirq migration issue.

Yep.  That looks like it.   In the genirq migration the edge and
level triggered cases got merged and previously disable_edge_ioapic
was a noop.  Ouch.

Darn I missed this one in my review of Ingos changes.

I'm not at all certain what the correct fix here is.
- Do we make the make the generic code aware of this messed up
  case?  I believe it is aware of part of the don't disable edge
  triggered interrupt logic already.
- Do we modify the disable logic so it doesn't actually disable the
  irq?
- Do we do as Linus suggests and make the enable logic pass through a
  level triggered state?
- Do we split the edge and level triggered cases apart on again on
  i386 and x86_64?

And how do we make it drop dead clear what we are doing so that
someone doesn't break this in the future by accident.  That I
suspect was the real problem.  That stupid vector == irq case had
introduced so many levels of abstraction it was nearly impossible
to read the code.

Can we get this abstraction right so that we can make obviously
correct code here and still handle all of the weird code bugs?

> Eric, can you please double-check this all? I suspect you disable 
> edge-triggered interrupts when moving them, or something, and maybe you 
> didn't realize that if you disable them on the IO-APIC level, they can be 
> gone forever.

Sure.  So the hypothesis is that it is somewhere near commit
e7b946e98a456077dd6897f726f3d6197bd7e3b9 causing the problem. 

Anything I have changed in this area should affect both i386 and 
x86_64.

> [ Note: this is true EVEN IF we are in the interrupt handler right then - 
>   if we get another edge while in the interrupt handler, the interrupt 
>   will normally be _delayed_ until we've ACK'ed it, but if we have 
>   _masked_ it, it will simply be lost entirely. So a simple "mask" 
>   operation is always incorrect for edge-triggered interrupts.
>
>   One option might be to do a simple mask, and on unmask, turn the edge 
>   trigger into a level trigger at the same time. Then, the first time you 
>   get the interrupt, you turn it back into an edge trigger _before_ you 
>   call the interrupt handlers. That might actually be simpler than doing 
>   the "irq replay" dance with self-IPI, because we can't actually just 
>   fake the IRQ handling - when enable_irq() is called, irq's are normally 
>   disabled on the CPU, so we can't just call the irq handler at that 
>   point: we really do need to "replay" the dang thing.
>
>   Did I mention that the Intel APIC's are a piece of cr*p already? ]

Ok. After a quick skim it appears that there is a disable/enable pair
in the irq migration path for edge triggered interrupts.  But we
do that work while the irq is pending and it doesn't look like I
changed that part of the code.  Just the level triggered irq
migration.

>> So I think enable_irq does not enable the irq.
>
> It probably does enable it (that's the easy part), but see above: if any 
> of the support structure for the APIC crapola is subtly broken, we'll have 
> lost the IRQ anyway.
>
> (Many other IRQ controllers get this right: the "old and broken" Intel 
> i8259 interrupt controller was a much better IRQ controller than the APIC 
> in this regard, because it simply had the edge-detect logic after the 
> masking logic, so if you unmasked an active interrupt that had been 
> masked, you would always see it as an edge, and the i8259 controller needs 
> none of the subtle code at _all_. It just works.)
>
> Anyway, if you _can_ bisect the exact point where this started happening, 
> that would be good. But I would not be surprised in the least if this is 
> all introduced by Eric Biedermans dynamic IRQ handling.

I will share the credit because I missed this in code review but this
is really Ingo's generic irq code. 

Eric

  reply	other threads:[~2006-11-13 17:13 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-08  2:33 Linux 2.6.19-rc5 Linus Torvalds
     [not found] ` <20061108085235.GT4729@stusta.de>
2006-11-08  9:29   ` [discuss] 2.6.19-rc5: known regressions Jan Beulich
2006-11-08 10:21     ` Adrian Bunk
2006-11-08  9:34   ` Jens Axboe
2006-11-08 19:09     ` Alex Romosan
2006-11-08 19:29       ` Jens Axboe
2006-11-08 19:38         ` Alex Romosan
2006-11-08 19:45           ` Jens Axboe
2006-11-08 21:40             ` Alex Romosan
2006-11-08 20:03         ` Arjan van de Ven
2006-11-08 20:19           ` Jens Axboe
2006-11-08 11:04   ` Eric W. Biederman
2006-11-08 11:32   ` Thomas Gleixner
     [not found]   ` <7813413.118221162987983254.komurojun-mbn@nifty.com>
2006-11-08 16:00     ` Linus Torvalds
2006-11-10 12:42     ` Re: Re: 2.6.19-rc5: known regressions :SMP kernel can not generate ISA irq Komuro
2006-11-13 16:02       ` Linus Torvalds
2006-11-13 17:11         ` Eric W. Biederman [this message]
2006-11-13 20:44           ` Ingo Molnar
2006-11-13 21:11             ` Eric W. Biederman
2006-11-14  8:14               ` [patch] irq: do not mask interrupts by default Ingo Molnar
2006-11-14  8:20                 ` Arjan van de Ven
2006-11-14 16:10                 ` Linus Torvalds
2006-11-14 17:52                   ` [PATCH] Use delayed disable mode of ioapic edge triggered interrupts Eric W. Biederman
2006-11-14 23:35                     ` Linus Torvalds
2006-11-15  1:17                     ` Linus Torvalds
2006-11-15  5:14                       ` Eric W. Biederman
2006-11-15 16:06                         ` Linus Torvalds
2006-11-15 16:58                           ` Eric W. Biederman
2006-11-15 12:40                   ` Komuro
     [not found]                   ` <20061115090427.GA16173@elte.hu>
2006-11-15 16:13                     ` [patch] genirq: do not mask interrupts by default Linus Torvalds
2006-11-15 17:46                       ` Ingo Molnar
2006-11-14 12:43               ` [patch] irq: " Komuro
     [not found]   ` <m1y7qm425l.fsf@ebiederm.dsl.xmission.com>
     [not found]     ` <Pine.LNX.4.64.0611080745150.3667@g5.osdl.org>
2006-11-08 16:22       ` 2.6.19-rc5: known regressions Adrian Bunk
2006-11-08 23:11         ` Tim Chen
2006-11-09  2:49           ` Tim Chen
2006-11-09  5:10             ` Eric W. Biederman
2006-11-13 22:46               ` Tim Chen
2006-11-14  0:03                 ` Eric W. Biederman
2006-11-08  9:43 ` Linux 2.6.19-rc5 Nigel Cunningham
2006-11-08  9:59   ` Alessandro Suardi
2006-11-08 10:04     ` Nigel Cunningham
2006-11-08 14:19     ` Gene Heskett
2006-11-08 15:43   ` Linus Torvalds
     [not found] ` <20061111015035.GU4729@stusta.de>
2006-11-11  9:08   ` [discuss] 2.6.19-rc5: known regressions (v2) Rafael J. Wysocki
2006-11-11  9:25     ` Paolo Ornati
2006-11-11 10:49       ` Rafael J. Wysocki
2006-11-11 12:29         ` Paolo Ornati
2006-11-14 16:44           ` Paolo Ornati
2006-11-29 10:10             ` [SOLVED] " Paolo Ornati
2006-11-13 22:14 ` 2.6.19-rc5: known regressions with patches Adrian Bunk
2006-11-13 22:56   ` Brian King
2006-11-13 23:15     ` Linus Torvalds
2006-11-14  2:35       ` Jeff Garzik
2006-11-15 10:21 ` 2.6.19-rc5: known regressions (v3) Adrian Bunk
2006-11-15 10:35   ` Jens Axboe
2006-11-15 10:53     ` Adrian Bunk
2006-11-15 10:35   ` Eric Dumazet
2006-11-15 10:50     ` Andi Kleen
2006-11-15 16:40       ` William Cohen
2006-11-15 16:48         ` [discuss] " Andi Kleen
2006-11-15 18:39           ` Andrew Morton
2006-11-15 18:45             ` Andi Kleen
2006-11-15 19:07               ` Linus Torvalds
2006-11-15 19:23                 ` Andi Kleen
2006-11-15 20:21                   ` Andrew Morton
2006-11-15 21:18                     ` Eric W. Biederman
2006-11-15 21:31                       ` Andrew Morton
2006-11-16 10:55                         ` Mikael Pettersson
2006-11-16 20:23                           ` Andrew Morton
2006-11-17  9:59                             ` Mikael Pettersson
2006-11-17 10:13                               ` Andrew Morton
2006-11-19  3:05                                 ` Bill Davidsen
2006-11-17 10:29                               ` Andi Kleen
2006-11-16  3:21                     ` Andi Kleen
2006-11-16  5:05                       ` Andrew Morton
2006-11-16  7:04                         ` Andi Kleen
2006-11-16 15:34                           ` William Cohen
2006-11-16 15:47                             ` Andi Kleen
2006-11-16 21:32                             ` Stephane Eranian
2006-11-22 10:28     ` Eric Dumazet
2006-11-22 10:36       ` Andi Kleen
2006-11-22 18:42         ` Andrew Morton
2006-12-16 11:20           ` Ray Lee
2006-11-22 17:59       ` William Cohen
2006-11-22 18:05       ` William Cohen
2006-11-22 18:26         ` Eric Dumazet
2006-11-15 11:06   ` Brice Goglin
2006-11-15 22:32     ` Adrian Bunk
2006-11-15 12:07   ` Alan
2006-11-15 15:52   ` Stephen Hemminger
2006-11-15 16:35     ` Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m13b8ns24j.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@osdl.org \
    --cc=bunk@stusta.de \
    --cc=komurojun-mbn@nifty.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome