[PATCHSET v3 sched_ext/for-7.3-fixes] sched_ext: Pass the initial cmask to cid-form ops.enable()
From: Tejun Heo
Date: Fri Sep 18 2026 - 20:31:02 EST
Hello,
v3: - The initial set_cmask() is delivered before set_weight() so that the
mask is in place when weight-dependent state is derived (Andrea Righi).
- Added a selftest checking the cmask enable() receives, the set_cmask()
that follows it and their ordering (Andrea Righi).
v2: https://lore.kernel.org/r/2f0eb5c762d55edba5365f1006dbb395@xxxxxxxxxx
v1: https://lore.kernel.org/r/c8343c2e457508a6cd3fcab66b0823b6@xxxxxxxxxx
A cid-form scheduler has no p->cpus_ptr equivalent to read. A task's cid
mask is only visible through ops.set_cmask(), which doesn't fire when a task
enters a scheduler through fork, sub-sched enable or re-home, so schedulers
seed the mask from p->cpus_ptr in ops.init_task(), and that seed goes stale
when affinity changes between init_task() and enable().
The first patch passes the initial cmask to cid-form ops.enable() through a
new args struct and has set_cmask() repeat it right after, so a scheduler can
track affinity in set_cmask() alone. The second adds a selftest for it.
Verified by building the kernel, tools/sched_ext and the selftests. The new
selftest passes on a 16-CPU VM, standalone three times and inside the full
sched_ext suite. scx_qmap ran under fork churn with a throwaway enable()
check comparing the delivered mask against p->cpus_ptr on about 55k enables
with no mismatch.
Based on sched_ext/for-7.3-fixes (9ec7ba20c97d).
This patchset contains the following 2 patches.
0001 sched_ext: Pass the initial cmask to cid-form ops.enable()
0002 selftests/sched_ext: Check the cmask cid-form ops.enable() receives
The patchset is also available in the following git branch:
git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git cid-enable-args-v3
diffstat follows. Thanks.
kernel/sched/ext/ext.c | 92 ++++++++++++++-------
kernel/sched/ext/internal.h | 56 +++++++++++--
tools/sched_ext/scx_qmap.bpf.c | 3 -
tools/testing/selftests/sched_ext/Makefile | 1 +
tools/testing/selftests/sched_ext/enable_cmask.bpf.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++
tools/testing/selftests/sched_ext/enable_cmask.c | 138 ++++++++++++++++++++++++++++++++
6 files changed, 462 insertions(+), 41 deletions(-)
--
tejun