]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched_ext: Mark waker CPU busy when selected in WAKE_SYNC case
authorKuba Piecuch <jpiecuch@google.com>
Wed, 22 Jul 2026 14:33:07 +0000 (14:33 +0000)
committerTejun Heo <tj@kernel.org>
Wed, 22 Jul 2026 17:55:28 +0000 (07:55 -1000)
commit9591fcc95dddfd24298724f8eb5239e907980779
treec83bcad506dc72f0bf1d1e1711a68a2ae21c32c6
parent5cdc928598095b2c7d5f265e5f21eadd1634bfbe
sched_ext: Mark waker CPU busy when selected in WAKE_SYNC case

SCX's built-in idle CPU tracking is imperfect and can be out-of-sync
with the actual idle state of CPUs, especially immediately after
enabling SCX due to scx_idle_enable() marking all online CPUs idle.

scx_select_cpu_dfl() skips marking the selected CPU as busy if
the selected CPU is the waker CPU in the SCX_WAKE_SYNC case.
If the waker CPU was marked idle by SCX, it will still be marked idle
after CPU selection and potentially even after switching to the wakee.

In the allowed_cpus selftest, this can manifest as the test failing with
the following message in dmesg:

  allowed_cpus.bpf.c:21: CPU 0 should be marked as busy

This patch explicitly marks the waker CPU as busy. With this patch,
the test failure no longer reproduces. There are still some pretty
unlikely races that could make the test fail (e.g. pick_task_idle()
marking the selected CPU idle between selection and validation), but
these can't be fixed easily.

Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext/idle.c