linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Valdis.Kletnieks@vt.edu
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>, Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] IRQ: Fix oneshot irq race between irq_finalize_oneshot and handle_level_irq
Date: Tue, 09 Mar 2010 11:59:05 -0500	[thread overview]
Message-ID: <5309.1268153945@localhost> (raw)
In-Reply-To: Your message of "Tue, 09 Mar 2010 08:58:11 +0100." <alpine.LFD.2.00.1003090855250.22855@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1562 bytes --]

On Tue, 09 Mar 2010 08:58:11 +0100, Thomas Gleixner said:
> On Tue, 9 Mar 2010, Lars-Peter Clausen wrote:
> 
> > If the kernel has been compiled with preemtion support and handle_level_irq is
> > called from process context for a oneshot irq there is a race between
> > irq_finalize_oneshot and handle_level_irq which results in the irq not being
> > unmasked after its handlers have been run.
> > 
> > irq_finalize_oneshot is expected to unmask the irq after the threaded irq
> > handler has been run. It only does so if IRQ_MASKED is set for the irqs status.
> > IRQ_MASKED gets set in the lower part of handle_level_irq after handle_IRQ_event
> > has been called.
> > handle_IRQ_event will wakeup the oneshot irqs threaded handler and if the
> > kernel has been build with preemption there is a chance that the threaded irq
> > handler will finish before execution is returned to handle_level_irq.
> > As a result irq_finalize_oneshot will not unmask the irq and handle_level_irq
> > will set the IRQ_MASKED flag. Thus the irq will stay masked and stalls.
> > 
> > In case of an race the call-graph would look like this:
> >  handle_level_irq
> >  |- mask_ack_irq
> >  |- handle_IRQ_event
> >     |- wake_up_process
> >        |- irq_thread
> >           |- action->thread_fn
> >           |- irq_finalize_oneshot # Does not unmask the irq
> > |- # Set IRQ_MASKED status flag
> 
> Errm, a thread _CANNOT_ preempt a hard interrupt handler.

What stops the thread from concurrently running on another CPU and racing
that way?  I'm an idiot, use small words. :)

[-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --]

  parent reply	other threads:[~2010-03-09 16:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-08 23:57 [RFC][PATCH] IRQ: Fix oneshot irq race between irq_finalize_oneshot and handle_level_irq Lars-Peter Clausen
2010-03-09  7:58 ` Thomas Gleixner
2010-03-09  8:08   ` Yong Zhang
2010-03-09 16:59   ` Valdis.Kletnieks [this message]
2010-03-09 18:10     ` Thomas Gleixner
2010-03-09 22:48       ` Lars-Peter Clausen
2010-03-09 23:32         ` Thomas Gleixner
2010-03-09 23:22 ` Thomas Gleixner
2010-03-10  3:21   ` Yong Zhang
2010-03-10  7:56     ` Thomas Gleixner
2010-03-11  2:55       ` Yong Zhang
2010-03-11  8:41         ` Thomas Gleixner
2010-03-11  9:13           ` Yong Zhang

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=5309.1268153945@localhost \
    --to=valdis.kletnieks@vt.edu \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).