The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH sched_ext/for-7.4-fixes 0/2] sched_ext: Fix two races between fork and scx_post_fork()
@ 2026-12-04  1:27 Hang Zhengyang
  2026-12-04  1:27 ` [PATCH sched_ext/for-7.4-fixes 1/2] sched_ext: Don't enable or disable a task being forked on class changes Hang Zhengyang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hang Zhengyang @ 2026-12-04  1:27 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Andrea Righi, Changwoo Min, Ingo Molnar,
	Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
	K Prateek Nayak
  Cc: Cheng-Yang Chou, Barret Rhoden, Josh Don, Hao Luo, sched-ext,
	linux-kernel

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-04 16:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  1:27 [PATCH sched_ext/for-7.4-fixes 0/2] sched_ext: Fix two races between fork and scx_post_fork() Hang Zhengyang
2026-12-04  1:27 ` [PATCH sched_ext/for-7.4-fixes 1/2] sched_ext: Don't enable or disable a task being forked on class changes Hang Zhengyang
2026-12-04  1:27 ` [PATCH sched_ext/for-7.4-fixes 2/2] sched_ext: Don't enable a task twice when it migrates during fork Hang Zhengyang
2026-12-04 16:41 ` [PATCH sched_ext/for-7.4-fixes 0/2] sched_ext: Fix two races between fork and scx_post_fork() Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox