From: Leonardo Bras <leobras@redhat.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Tony Lindgren" <tony@atomide.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"John Ogness" <john.ogness@linutronix.de>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Leonardo Bras" <leobras@redhat.com>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Shanker Donthineni" <sdonthineni@nvidia.com>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: [RFC PATCH v2 0/4] Fix force_irqthread + fast triggered edge-type IRQs
Date: Fri, 16 Feb 2024 04:59:42 -0300 [thread overview]
Message-ID: <20240216075948.131372-2-leobras@redhat.com> (raw)
v1 patchset subject was "Fix serial console for PREEMPT_RT".
While dealing with a bug that breaks the serial console from qemu (8250)
after printing a lot of data, I found some issues on this driver on
PREEMPT_RT kernel due to it enabling force_irqthreads, ending up causing
the IRQ to be disabled and the serial console to go down.
I found out 8250 driver get an IRQ request for every tx byte, but the
handler is able to deal with sending multiple bytes per "thread wake up".
If the thread don't get to run that often, and end up handling many irqs at
once, it will cause few changes in threads_handled to be noticed, meaning
only a few runs of note_interrupt will not increment irqs_unhandled, which
leads to disabling the IRQ.
For serial8250, to trigger IRQ disabling it's only needed a fast printing
of ~300kBytes.
In order to fix this, I propose that we subtract the number of threads
handled since the last note_interrupt from irqs_unhandled:
(irqs_unhandled -= threads_handled - threads_handled_last)
So this way irqs_unhandled actually reflects how many of those irqs
actually haven't been handled.
This work is divided in:
Patch #1: Simple change in SPURIOUS_DEFERRED bit (31 -> 0), so we can
acuratelly measure how many IRQs have been handled even when the
threads_handled & threads_handled_last are close to overflow.
Patch #2: Subtract the diff from irqs_unhandled on note_interrupt.
Patch #3: Implement IRQ_HANDLED_MANY in order to let the handler return how
many interruptions have been handled in a single run, and increment
threads_handled accordingly.
Patch #4: Change serial8250 driver to use IRQ_HANDLED_MANY interface,
so it can inform how many IRQs have been handled, and help set the correct
number of irqs_unhandled, thus avoiding IRQ disabled for normal usage.
Changes since RFCv1:
- Implemented a way of better counting threaded_irqs handled, instead of
only zeroing irqs_unhandled.
- Rebased on top of linux-rt/v6.8-rc4-rt4-rebase, so I don't need to fix
the sleep while atomic issue in serial8250 mainline.
- Better description of what we are actually fixing
- Changed patchset title from "Fix serial console for PREEMPT_RT"
- Link: https://lore.kernel.org/all/20240116073701.2356171-1-leobras@redhat.com/
Leonardo Bras (4):
irq: Move spurious_deferred bit from BIT(31) to BIT(0)
irq/spurious: Account for multiple handles in note_interrupt
irq: Introduce IRQ_HANDLED_MANY
tty/serial8250: Make use of IRQ_HANDLED_MANY interface
include/linux/irqdesc.h | 11 +++++-
include/linux/irqreturn.h | 23 +++++++++++-
include/linux/serial_8250.h | 2 +-
drivers/tty/serial/8250/8250_core.c | 13 ++++---
drivers/tty/serial/8250/8250_port.c | 16 +++++----
kernel/irq/chip.c | 10 ++++--
kernel/irq/handle.c | 3 ++
kernel/irq/manage.c | 8 +++--
kernel/irq/spurious.c | 55 ++++++++++++++++++-----------
9 files changed, 102 insertions(+), 39 deletions(-)
base-commit: 63d966ad6fecb66769e56fe2285de1e3b448f2ff
--
2.43.2
next reply other threads:[~2024-02-16 8:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 7:59 Leonardo Bras [this message]
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
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=20240216075948.131372-2-leobras@redhat.com \
--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