* [PATCH v1 0/2] genirq: refactor irq_forced_thread_fn()
@ 2024-11-19 10:42 Andy Shevchenko
2024-11-19 10:42 ` [PATCH v1 1/2] genirq: Move irq_forced_thread_fn() further in the code Andy Shevchenko
2024-11-19 10:42 ` [PATCH v1 2/2] genirq: Reuse irq_thread_fn() for forced thread case Andy Shevchenko
0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-19 10:42 UTC (permalink / raw)
To: linux-kernel, llvm
Cc: Thomas Gleixner, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Shevchenko
The irq_forced_thread_fn() open codes the irq_forced_fn().
Refactor to reuse.
Andy Shevchenko (2):
genirq: Move irq_forced_thread_fn() further in the code
genirq: Reuse irq_thread_fn() for forced thread case
kernel/irq/manage.c | 46 +++++++++++++++++++++------------------------
1 file changed, 21 insertions(+), 25 deletions(-)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/2] genirq: Move irq_forced_thread_fn() further in the code
2024-11-19 10:42 [PATCH v1 0/2] genirq: refactor irq_forced_thread_fn() Andy Shevchenko
@ 2024-11-19 10:42 ` Andy Shevchenko
2024-12-03 11:02 ` [tip: irq/core] genirq: Move irq_thread_fn() further up " tip-bot2 for Andy Shevchenko
2024-11-19 10:42 ` [PATCH v1 2/2] genirq: Reuse irq_thread_fn() for forced thread case Andy Shevchenko
1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-19 10:42 UTC (permalink / raw)
To: linux-kernel, llvm
Cc: Thomas Gleixner, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Shevchenko
In a preparation of the refactoring, move irq_forced_thread_fn()
further in the code. No functional changes intented.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/irq/manage.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index f0803d6bd296..310fbeed4d7a 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1181,6 +1181,24 @@ static void irq_finalize_oneshot(struct irq_desc *desc,
chip_bus_sync_unlock(desc);
}
+/*
+ * Interrupts explicitly requested as threaded interrupts want to be
+ * preemptible - many of them need to sleep and wait for slow busses to
+ * complete.
+ */
+static irqreturn_t irq_thread_fn(struct irq_desc *desc,
+ struct irqaction *action)
+{
+ irqreturn_t ret;
+
+ ret = action->thread_fn(action->irq, action->dev_id);
+ if (ret == IRQ_HANDLED)
+ atomic_inc(&desc->threads_handled);
+
+ irq_finalize_oneshot(desc, action);
+ return ret;
+}
+
/*
* Interrupts which are not explicitly requested as threaded
* interrupts rely on the implicit bh/preempt disable of the hard irq
@@ -1206,24 +1224,6 @@ irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
return ret;
}
-/*
- * Interrupts explicitly requested as threaded interrupts want to be
- * preemptible - many of them need to sleep and wait for slow busses to
- * complete.
- */
-static irqreturn_t irq_thread_fn(struct irq_desc *desc,
- struct irqaction *action)
-{
- irqreturn_t ret;
-
- ret = action->thread_fn(action->irq, action->dev_id);
- if (ret == IRQ_HANDLED)
- atomic_inc(&desc->threads_handled);
-
- irq_finalize_oneshot(desc, action);
- return ret;
-}
-
void wake_threads_waitq(struct irq_desc *desc)
{
if (atomic_dec_and_test(&desc->threads_active))
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 2/2] genirq: Reuse irq_thread_fn() for forced thread case
2024-11-19 10:42 [PATCH v1 0/2] genirq: refactor irq_forced_thread_fn() Andy Shevchenko
2024-11-19 10:42 ` [PATCH v1 1/2] genirq: Move irq_forced_thread_fn() further in the code Andy Shevchenko
@ 2024-11-19 10:42 ` Andy Shevchenko
2024-12-03 11:02 ` [tip: irq/core] " tip-bot2 for Andy Shevchenko
1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-19 10:42 UTC (permalink / raw)
To: linux-kernel, llvm
Cc: Thomas Gleixner, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Shevchenko
The irq_forced_thread_fn() uses the same action callback
as the non-forced variant but with different locking decorations.
Reuse irq_thread_fn() here to make that clear.
bloat-o-meter statistics on x86_64 (GCC-13, clang-18 shows no difference):
Function old new delta
irq_forced_thread_fn 118 55 -63
Total: Before=13845, After=13782, chg -0.46%
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/irq/manage.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 310fbeed4d7a..2d9993f86fde 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1213,11 +1213,7 @@ irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
local_bh_disable();
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_disable();
- ret = action->thread_fn(action->irq, action->dev_id);
- if (ret == IRQ_HANDLED)
- atomic_inc(&desc->threads_handled);
-
- irq_finalize_oneshot(desc, action);
+ ret = irq_thread_fn(desc, action);
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_enable();
local_bh_enable();
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: irq/core] genirq: Reuse irq_thread_fn() for forced thread case
2024-11-19 10:42 ` [PATCH v1 2/2] genirq: Reuse irq_thread_fn() for forced thread case Andy Shevchenko
@ 2024-12-03 11:02 ` tip-bot2 for Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Andy Shevchenko @ 2024-12-03 11:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Andy Shevchenko, Thomas Gleixner, x86, linux-kernel, maz
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 429f49ad361cd999ca221d8b562ae2552b7c3e2c
Gitweb: https://git.kernel.org/tip/429f49ad361cd999ca221d8b562ae2552b7c3e2c
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Tue, 19 Nov 2024 12:42:35 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 03 Dec 2024 11:59:10 +01:00
genirq: Reuse irq_thread_fn() for forced thread case
rq_forced_thread_fn() uses the same action callback as the non-forced
variant but with different locking decorations. Reuse irq_thread_fn() here
to make that clear.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241119104339.2112455-3-andriy.shevchenko@linux.intel.com
---
kernel/irq/manage.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 230f470..f300bb6 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1210,11 +1210,7 @@ static irqreturn_t irq_forced_thread_fn(struct irq_desc *desc, struct irqaction
local_bh_disable();
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_disable();
- ret = action->thread_fn(action->irq, action->dev_id);
- if (ret == IRQ_HANDLED)
- atomic_inc(&desc->threads_handled);
-
- irq_finalize_oneshot(desc, action);
+ ret = irq_thread_fn(desc, action);
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_enable();
local_bh_enable();
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: irq/core] genirq: Move irq_thread_fn() further up in the code
2024-11-19 10:42 ` [PATCH v1 1/2] genirq: Move irq_forced_thread_fn() further in the code Andy Shevchenko
@ 2024-12-03 11:02 ` tip-bot2 for Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Andy Shevchenko @ 2024-12-03 11:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Andy Shevchenko, Thomas Gleixner, x86, linux-kernel, maz
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 6f8b79683dfb37ee0661cf4c13a72f024c29f65c
Gitweb: https://git.kernel.org/tip/6f8b79683dfb37ee0661cf4c13a72f024c29f65c
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Tue, 19 Nov 2024 12:42:34 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 03 Dec 2024 11:59:10 +01:00
genirq: Move irq_thread_fn() further up in the code
In a preparation to reuse irq_thread_fn() move it further up in the
code. No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241119104339.2112455-2-andriy.shevchenko@linux.intel.com
---
kernel/irq/manage.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index f0803d6..230f470 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1182,45 +1182,42 @@ out_unlock:
}
/*
- * Interrupts which are not explicitly requested as threaded
- * interrupts rely on the implicit bh/preempt disable of the hard irq
- * context. So we need to disable bh here to avoid deadlocks and other
- * side effects.
+ * Interrupts explicitly requested as threaded interrupts want to be
+ * preemptible - many of them need to sleep and wait for slow busses to
+ * complete.
*/
-static irqreturn_t
-irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
+static irqreturn_t irq_thread_fn(struct irq_desc *desc, struct irqaction *action)
{
- irqreturn_t ret;
+ irqreturn_t ret = action->thread_fn(action->irq, action->dev_id);
- local_bh_disable();
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- local_irq_disable();
- ret = action->thread_fn(action->irq, action->dev_id);
if (ret == IRQ_HANDLED)
atomic_inc(&desc->threads_handled);
irq_finalize_oneshot(desc, action);
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- local_irq_enable();
- local_bh_enable();
return ret;
}
/*
- * Interrupts explicitly requested as threaded interrupts want to be
- * preemptible - many of them need to sleep and wait for slow busses to
- * complete.
+ * Interrupts which are not explicitly requested as threaded
+ * interrupts rely on the implicit bh/preempt disable of the hard irq
+ * context. So we need to disable bh here to avoid deadlocks and other
+ * side effects.
*/
-static irqreturn_t irq_thread_fn(struct irq_desc *desc,
- struct irqaction *action)
+static irqreturn_t irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
{
irqreturn_t ret;
+ local_bh_disable();
+ if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+ local_irq_disable();
ret = action->thread_fn(action->irq, action->dev_id);
if (ret == IRQ_HANDLED)
atomic_inc(&desc->threads_handled);
irq_finalize_oneshot(desc, action);
+ if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+ local_irq_enable();
+ local_bh_enable();
return ret;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-03 11:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-19 10:42 [PATCH v1 0/2] genirq: refactor irq_forced_thread_fn() Andy Shevchenko
2024-11-19 10:42 ` [PATCH v1 1/2] genirq: Move irq_forced_thread_fn() further in the code Andy Shevchenko
2024-12-03 11:02 ` [tip: irq/core] genirq: Move irq_thread_fn() further up " tip-bot2 for Andy Shevchenko
2024-11-19 10:42 ` [PATCH v1 2/2] genirq: Reuse irq_thread_fn() for forced thread case Andy Shevchenko
2024-12-03 11:02 ` [tip: irq/core] " tip-bot2 for Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®