linux-rt-devel.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Crystal Wood <crwood@redhat.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
	Oliver O'Halloran <oohall@gmail.com>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Attila Fazekas <afazekas@redhat.com>,
	linux-pci@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH] PCI/AER: Use IRQF_NO_THREAD on aer_irq
Date: Mon, 8 Sep 2025 08:36:32 +0200	[thread overview]
Message-ID: <aL55cDBjsNk2xK10@wunner.de> (raw)
In-Reply-To: <bb2b9df1b13fccb7829c5d73a0bddbd0083d105a.camel@redhat.com>

On Thu, Sep 04, 2025 at 03:27:40PM -0500, Crystal Wood wrote:
> On Thu, 2025-09-04 at 14:48 +0200, Lukas Wunner wrote:
> > On Thu, Sep 04, 2025 at 09:30:24AM +0200, Sebastian Andrzej Siewior wrote:
> > > Another way would be to let the secondary handler run at a slightly lower
> > > priority than the primary handler. In this case making the primary
> > > non-threaded should not cause any harm.
> > 
> > Why isn't the secondary handler always assigned a lower priority
> > by default?  I think a lot of drivers are built on the assumption
> > that the primary handler is scheduled sooner than the secondary
> > handler.
> 
> That also works, and I agree it's more intuitive.

Could you test whether the patch below fixes the issue for you?

-- >8 --

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2b27238..ceed23d 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1894,6 +1894,7 @@ static inline int task_nice(const struct task_struct *p)
 extern int sched_setscheduler(struct task_struct *, int, const struct sched_param *);
 extern int sched_setscheduler_nocheck(struct task_struct *, int, const struct sched_param *);
 extern void sched_set_fifo(struct task_struct *p);
+extern void sched_set_fifo_minus_one(struct task_struct *p);
 extern void sched_set_fifo_low(struct task_struct *p);
 extern void sched_set_normal(struct task_struct *p, int nice);
 extern int sched_setattr(struct task_struct *, const struct sched_attr *);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index c948373..b09c18a 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1239,7 +1239,10 @@ static int irq_thread(void *data)
 
 	irq_thread_set_ready(desc, action);
 
-	sched_set_fifo(current);
+	if (action->handler == irq_forced_secondary_handler)
+		sched_set_fifo_minus_one(current);
+	else
+		sched_set_fifo(current);
 
 	if (force_irqthreads() && test_bit(IRQTF_FORCED_THREAD,
 					   &action->thread_flags))
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index 77ae87f..8234223 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -847,6 +847,15 @@ void sched_set_fifo(struct task_struct *p)
 EXPORT_SYMBOL_GPL(sched_set_fifo);
 
 /*
+ * Secondary IRQ handler has slightly lower priority than primary IRQ handler.
+ */
+void sched_set_fifo_minus_one(struct task_struct *p)
+{
+	struct sched_param sp = { .sched_priority = MAX_RT_PRIO / 2 - 1 };
+	WARN_ON_ONCE(sched_setscheduler_nocheck(p, SCHED_FIFO, &sp) != 0);
+}
+
+/*
  * For when you don't much care about FIFO, but want to be above SCHED_NORMAL.
  */
 void sched_set_fifo_low(struct task_struct *p)

  reply	other threads:[~2025-09-08  6:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 22:44 [PATCH] PCI/AER: Use IRQF_NO_THREAD on aer_irq Crystal Wood
2025-09-03  8:10 ` Lukas Wunner
2025-09-03 21:39   ` Crystal Wood
2025-09-04  7:30 ` Sebastian Andrzej Siewior
2025-09-04 12:48   ` Lukas Wunner
2025-09-04 13:18     ` Lukas Wunner
2025-09-04 13:38       ` Sebastian Andrzej Siewior
2025-09-04 13:31     ` Sebastian Andrzej Siewior
2025-09-04 20:27     ` Crystal Wood
2025-09-08  6:36       ` Lukas Wunner [this message]
2025-09-08  7:52         ` Sebastian Andrzej Siewior
2025-09-08 15:02           ` Crystal Wood

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=aL55cDBjsNk2xK10@wunner.de \
    --to=lukas@wunner.de \
    --cc=afazekas@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=crwood@redhat.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=mahesh@linux.ibm.com \
    --cc=oohall@gmail.com \
    --cc=rostedt@goodmis.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).