linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: David Laight <David.Laight@ACULAB.COM>
Cc: "casey.fitzpatrick@timesys.com" <casey.fitzpatrick@timesys.com>,
	"lukas@wunner.de" <lukas@wunner.de>,
	"mingo@kernel.org" <mingo@kernel.org>,
	"m.duckeck@kunbus.de" <m.duckeck@kunbus.de>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"akshay.bhat@timesys.com" <akshay.bhat@timesys.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-tip-commits@vger.kernel.org" 
	<linux-tip-commits@vger.kernel.org>
Subject: RE: [tip:irq/core] genirq: Fix race on spurious interrupt detection
Date: Fri, 19 Oct 2018 22:26:22 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1810192221060.1651@nanos.tec.linutronix.de> (raw)
In-Reply-To: <alpine.DEB.2.21.1810192039200.1651@nanos.tec.linutronix.de>

David,

On Fri, 19 Oct 2018, Thomas Gleixner wrote:
> On Fri, 19 Oct 2018, David Laight wrote:
> > From: Lukas Wunner
> > > Sent: 19 October 2018 16:34
> > > 
> > > genirq: Fix race on spurious interrupt detection
> > > 
> > > Commit 1e77d0a1ed74 ("genirq: Sanitize spurious interrupt detection of
> > > threaded irqs") made detection of spurious interrupts work for threaded
> > > handlers by:
> > > 
> > > a) incrementing a counter every time the thread returns IRQ_HANDLED, and
> > > b) checking whether that counter has increased every time the thread is
> > >    woken.
> > 
> > That seems horribly broken.
> > What is it trying to achieve?
> > 
> > There are (at least) two common cases where IRQ_HANDLED doesn't get returned.
> > (Unless the driver always returns it to avoid the message.)
> > 
> > 1) The IOW that causes the hardware to drop a level sensitive IRQ is posted
> >    on the bus (etc) and happens late enough that the IRQ line is still
> >    asserted when the iret executes.
> >    If this happens all the time you need to flush the IOW, but if only
> >    occasionally it doesn't matter and you don't want a message.
> >
> > 2) Typically an ethernet driver ISR has to enable the interrupt and then
> >    check the ring for work before returning from the interrupt.
> >    If a packet arrives at this time it might be processed by the 'old'
> >    ISR invocation but still generate another interrupt.
> >    If no more packets arrive the second ISR invocation will find no work.
> >    Again this is normal behaviour.
> >    (Deferring everything with NAPI might make this not happen - but other
> >    interrupts end up working the same way.)
> > 
> > If you are really trying to detect 'stuck' interrupts then you probably
> > want to count un-handled ones and zero the count on handled ones.
> > I'm also pretty sure you don't need an atomic counter.
> 
> Care to look at the logic which handles all of this including the
> interaction with threaded interrupt handlers?

Sorry for being dense. Wanted to postpone and hit send ...

The thing is that the spurious detector works perfectly fine for the
scenarios you described since years. It does proper handled vs. unhandled
accounting.

What Lukas is addressing is not the normal interrupt case, it's the
threaded handler case where we did the accounting check after reenabling
the interrupt, which causes spurious detection to trigger
occasionally. That's not leading to disabling the interrupt unless you
enforce it with a gazillion of printks.

The atomic counter is necessary in that case because for certain scenarios
the hard interrupt handler can race with the threaded handler legitimately.

Thanks,

	tglx

      reply	other threads:[~2018-10-19 20:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 13:15 [PATCH] genirq: Fix race on spurious interrupt detection Lukas Wunner
2018-10-19 14:31 ` Thomas Gleixner
2018-10-19 15:23   ` Lukas Wunner
2018-10-19 15:26     ` Thomas Gleixner
2018-10-19 15:33 ` [tip:irq/core] " tip-bot for Lukas Wunner
2018-10-19 16:14   ` David Laight
2018-10-19 18:41     ` Thomas Gleixner
2018-10-19 20:26       ` Thomas Gleixner [this message]

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=alpine.DEB.2.21.1810192221060.1651@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=David.Laight@ACULAB.COM \
    --cc=akshay.bhat@timesys.com \
    --cc=casey.fitzpatrick@timesys.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=m.duckeck@kunbus.de \
    --cc=mingo@kernel.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;
as well as URLs for NNTP newsgroup(s).