diff options
| author | Kuba Piecuch <jpiecuch@google.com> | 2026-11-18 10:24:52 +0000 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2026-11-18 22:54:33 -1000 |
| commit | 8e156b9218f9f1f8b866d8e253145afdb01cf289 (patch) | |
| tree | 87bc08fe1fdaf383f9bcee5163b9eb6169bc1254 /tools/perf/scripts/python/event_analyzing_sample.py | |
| parent | 700a332c3fe33014bbd5ae852d71ba679fc29e0a (diff) | |
sched_ext: Don't route tasks to SCX before __scx_enabled is fully patched
scx_root_enable_workfn() sets scx_switching_all and calls
static_branch_enable(&__scx_enabled) before switching tasks, and
task_should_scx() gates only on scx_enabled(). static_branch_enable()
patches jump-label sites in address order rather than atomically:
task_should_scx() may be patched before __schedule().
If a concurrent fork or sched_setscheduler() runs in that window,
task_should_scx() observes scx_enabled() and moves the running task
from fair_sched_class to ext_sched_class, setting need_resched on the
class degradation. The following __schedule() can still observe
!scx_enabled() in next_active_class(), skip ext_sched_class, and pick
rq->idle while the runnable SCX task is still rq->donor:
WARNING: kernel/sched/ext/ext.c:3840 at put_prev_task_scx+0x405/0x7a0
Sched_ext: enq_select_cpu (enabling+all), task: runnable_at=+0ms
Call Trace:
__schedule+0x5cc/0x1100
preempt_schedule_common+0x12/0x40
preempt_schedule_thunk+0x16/0x40
__sched_setscheduler+0x8d8/0x920
Gate task_should_scx() on a scx_task_switch_enabled flag that is set with
release semantics only after static_branch_enable(&__scx_enabled) has
finished patching all call sites and scx_switching_all is updated, and
cleared on disable alongside scx_switching_all.
This bug was found and the patch was written with the help of an AI
coding assistant.
Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Tested-by: Tao Cui <cuitao@kylinos.cn>
Reviewed-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/event_analyzing_sample.py')
0 files changed, 0 insertions, 0 deletions
