From: Leonardo Bras <leobras@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Leonardo Bras" <leobras@redhat.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Tony Lindgren" <tony@atomide.com>,
"John Ogness" <john.ogness@linutronix.de>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Shanker Donthineni" <sdonthineni@nvidia.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [RFC PATCH v2 2/4] irq/spurious: Account for multiple handles in note_interrupt
Date: Fri, 16 Feb 2024 17:18:15 -0300 [thread overview]
Message-ID: <Zc_DBym2GuwPmAne@LeoBras> (raw)
In-Reply-To: <Zc-BBQGauwIEJJXy@smile.fi.intel.com>
On Fri, Feb 16, 2024 at 05:36:37PM +0200, Andy Shevchenko wrote:
> On Fri, Feb 16, 2024 at 04:59:44AM -0300, Leonardo Bras wrote:
> > Currently note_interrupt() will check threads_handled for changes and use
> > it to mark an IRQ as handled, in order to avoid having a threaded
> > interrupt to falsely trigger unhandled IRQ detection.
> >
> > This detection can still be falsely triggered if we have many IRQ handled
> > accounted between each check of threads_handled, as those will be counted
> > as a single one in the unhandled IRQ detection.
> >
> > In order to fix this, subtract from irqs_unhandled the number of IRQs
> > handled since the last check (threads_handled_last - threads_handled).
>
> ...
>
> > +static inline int get_handled_diff(struct irq_desc *desc)
> > +{
> > + unsigned int handled;
> > + int diff;
> > +
> > + handled = (unsigned int)atomic_read(&desc->threads_handled);
> > + handled |= SPURIOUS_DEFERRED;
> > +
> > + diff = handled - desc->threads_handled_last;
> > + diff >>= SPURIOUS_DEFERRED_SHIFT;
> > +
> > + /*
> > + * Note: We keep the SPURIOUS_DEFERRED bit set. We are handling the
> > + * previous invocation right now. Keep it for the current one, so the
> > + * next hardware interrupt will account for it.
> > + */
>
Hello Andy, thanks for reviewing!
> > + if (diff != 0)
>
> if (diff)
Sure
>
> > + desc->threads_handled_last = handled;
> > +
> > + return diff;
> > +}
>
> ...
>
> > + diff = get_handled_diff(desc);
> > + if (diff > 0) {
>
> diff may not be negative as you always right shift by 1 (or more) bit.
Agree
> Hence
>
> if (diff)
>
> will suffice (also be aligned with the similar check inside the helper) and
> making the helper to return unsigned value will be clearer. Am I correct?
Sure, you are correct.
I just think having it be (diff > 0) makes it clear that we only do the
subtraction if diff is bigger than zero, while (diff) could mean diff being
valid, and would require the reader to go back in code to see that diff is
an int.
Does it make sense?
Other than that, I agree the negative half of diff is never going to get
used, and it's better to go with unsigned int in both cases.
That will be changed on the next version.
Thanks!
Leo
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
next prev parent reply other threads:[~2024-02-16 20:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 7:59 [RFC PATCH v2 0/4] Fix force_irqthread + fast triggered edge-type IRQs Leonardo Bras
2024-02-16 7:59 ` [RFC PATCH v2 1/4] irq: Move spurious_deferred bit from BIT(31) to BIT(0) Leonardo Bras
2024-02-16 7:59 ` [RFC PATCH v2 2/4] irq/spurious: Account for multiple handles in note_interrupt Leonardo Bras
2024-02-16 15:36 ` Andy Shevchenko
2024-02-16 20:18 ` Leonardo Bras [this message]
2024-02-16 7:59 ` [RFC PATCH v2 3/4] irq: Introduce IRQ_HANDLED_MANY Leonardo Bras
2024-02-19 9:59 ` Thomas Gleixner
2024-02-19 11:03 ` Thomas Gleixner
2024-02-21 5:39 ` Leonardo Bras
2024-02-21 15:41 ` Thomas Gleixner
2024-02-21 17:04 ` Thomas Gleixner
2024-02-23 4:52 ` Leonardo Bras
2024-02-23 4:37 ` Leonardo Bras
2024-02-23 7:33 ` Thomas Gleixner
2024-11-14 3:40 ` Leonardo Bras
2024-11-14 7:50 ` Andy Shevchenko
2024-11-19 1:15 ` Leonardo Bras
2024-11-19 10:06 ` Andy Shevchenko
2024-12-02 22:53 ` Thomas Gleixner
2024-02-16 7:59 ` [RFC PATCH v2 4/4] tty/serial8250: Make use of IRQ_HANDLED_MANY interface Leonardo Bras
2024-02-16 10:12 ` Ilpo Järvinen
2024-02-16 19:58 ` Leonardo Bras
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=Zc_DBym2GuwPmAne@LeoBras \
--to=leobras@redhat.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=sdonthineni@nvidia.com \
--cc=tglx@linutronix.de \
--cc=tony@atomide.com \
--cc=u.kleine-koenig@pengutronix.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).