[PATCH sched_ext/for-7.4-fixes 0/2] sched_ext: Fix two races between fork and scx_post_fork()

From: Hang Zhengyang

Date: Thu Dec 03 2026 - 20:28:00 EST


Before scx_post_fork() runs, a new task can be reached by
sched_setscheduler() (patch 1, since v6.12) and by a cgroup migration to
another sub-scheduler (patch 2). Either can make ops.enable() run twice
or trip the task state check.

Tested on for-7.4-fixes with KASAN and lockdep. With a debug-only delay
before scx_post_fork(), all seven class change and migration cases warn
or enable tasks twice before and are clean after. Without the delay, 700
seconds of migrations enable 38 of 46133 tasks twice before and 0 of
44149 after. The sched_ext selftests pass.

Andrea Righi's pending "sched: Let switching_to() decide whether to keep
a retained proxy donor" makes switching_to_scx() return bool, so patch 1
will need a return value there.

I used Claude Code to find the issues, write the patches and run the
tests. I reviewed the patches.

Hang Zhengyang (2):
sched_ext: Don't enable or disable a task being forked on class
changes
sched_ext: Don't enable a task twice when it migrates during fork

kernel/sched/ext/ext.c | 32 +++++++++++++++++++++-----------
kernel/sched/ext/sub.c | 26 +++++++++++++++++++-------
2 files changed, 40 insertions(+), 18 deletions(-)


base-commit: b2b011d3d9cd7e01308ba8fa5775dcd1f2f11f70
--
2.53.0