public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Fix possible deadlock in the deferred_irq_workfn()
@ 2025-11-13 11:43 Zqiang
  2025-11-13 18:32 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Zqiang @ 2025-11-13 11:43 UTC (permalink / raw)
  To: tj, void, arighi, changwoo; +Cc: sched-ext, linux-kernel, qiang.zhang

For PREEMPT_RT=y kernels, the deferred_irq_workfn() is executed in
the per-cpu irq_work/* task context and not disable-irq, if the rq
returned by container_of() is current CPU's rq, the following scenarios
may occur:

lock(&rq->__lock);
<Interrupt>
  lock(&rq->__lock);

This commit use IRQ_WORK_INIT_HARD() to replace init_irq_work() to
initialize rq->scx.deferred_irq_work, make the deferred_irq_workfn()
is always invoked in hard-irq context.

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 kernel/sched/ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 2b0e88206d07..747b0d8528ab 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -5225,7 +5225,7 @@ void __init init_sched_ext_class(void)
 		BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_kick_if_idle, GFP_KERNEL, n));
 		BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_preempt, GFP_KERNEL, n));
 		BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_wait, GFP_KERNEL, n));
-		init_irq_work(&rq->scx.deferred_irq_work, deferred_irq_workfn);
+		rq->scx.deferred_irq_work = IRQ_WORK_INIT_HARD(deferred_irq_workfn);
 		init_irq_work(&rq->scx.kick_cpus_irq_work, kick_cpus_irq_workfn);
 
 		if (cpu_online(cpu))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sched_ext: Fix possible deadlock in the deferred_irq_workfn()
  2025-11-13 11:43 [PATCH] sched_ext: Fix possible deadlock in the deferred_irq_workfn() Zqiang
@ 2025-11-13 18:32 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2025-11-13 18:32 UTC (permalink / raw)
  To: Zqiang; +Cc: void, arighi, changwoo, sched-ext, linux-kernel

On Thu, Nov 13, 2025 at 07:43:55PM +0800, Zqiang wrote:
> For PREEMPT_RT=y kernels, the deferred_irq_workfn() is executed in
> the per-cpu irq_work/* task context and not disable-irq, if the rq
> returned by container_of() is current CPU's rq, the following scenarios
> may occur:
>
> lock(&rq->__lock);
> <Interrupt>
>   lock(&rq->__lock);
>
> This commit use IRQ_WORK_INIT_HARD() to replace init_irq_work() to
> initialize rq->scx.deferred_irq_work, make the deferred_irq_workfn()
> is always invoked in hard-irq context.
>
> Signed-off-by: Zqiang <qiang.zhang@linux.dev>

Applied to sched_ext/for-6.18-fixes.

Thanks.

--
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-13 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13 11:43 [PATCH] sched_ext: Fix possible deadlock in the deferred_irq_workfn() Zqiang
2025-11-13 18:32 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox