]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched_ext: Fix SCX_KICK_WAIT deadlock by deferring wait to balance callback
authorTejun Heo <tj@kernel.org>
Sun, 29 Mar 2026 00:18:55 +0000 (14:18 -1000)
committerTejun Heo <tj@kernel.org>
Mon, 30 Mar 2026 18:37:27 +0000 (08:37 -1000)
commit415cb193bb9736f0e830286c72a6fa8eb2a9cc5c
tree546fbe572531fa63ca266e54c4a77cc80349996f
parentdb08b1940f4beb25460b4a4e9da3446454f2e8fe
sched_ext: Fix SCX_KICK_WAIT deadlock by deferring wait to balance callback

SCX_KICK_WAIT busy-waits in kick_cpus_irq_workfn() using
smp_cond_load_acquire() until the target CPU's kick_sync advances. Because
the irq_work runs in hardirq context, the waiting CPU cannot reschedule and
its own kick_sync never advances. If multiple CPUs form a wait cycle, all
CPUs deadlock.

Replace the busy-wait in kick_cpus_irq_workfn() with resched_curr() to
force the CPU through do_pick_task_scx(), which queues a balance callback
to perform the wait. The balance callback drops the rq lock and enables
IRQs following the sched_core_balance() pattern, so the CPU can process
IPIs while waiting. The local CPU's kick_sync is advanced on entry to
do_pick_task_scx() and continuously during the wait, ensuring any CPU that
starts waiting for us sees the advancement and cannot form cyclic
dependencies.

Fixes: 90e55164dad4 ("sched_ext: Implement SCX_KICK_WAIT")
Cc: stable@vger.kernel.org # v6.12+
Reported-by: Christian Loehle <christian.loehle@arm.com>
Link: https://lore.kernel.org/r/20260316100249.1651641-1-christian.loehle@arm.com
Signed-off-by: Tejun Heo <tj@kernel.org>
Tested-by: Christian Loehle <christian.loehle@arm.com>
kernel/sched/ext.c
kernel/sched/sched.h