]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched_ext: Fix possible deadlock in the deferred_irq_workfn()
authorZqiang <qiang.zhang@linux.dev>
Thu, 13 Nov 2025 11:43:55 +0000 (19:43 +0800)
committerTejun Heo <tj@kernel.org>
Thu, 13 Nov 2025 18:29:28 +0000 (08:29 -1000)
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>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c

index 03d05ea200065b5f2858c1e579818ec89749156f..07399210ac2d9a38dfb60caabded0fbe12cb78eb 100644 (file)
@@ -5321,7 +5321,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))