diff options
| author | Michal Blaszczyk <michalblk@google.com> | 2026-11-10 15:18:57 +0000 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2026-11-18 14:32:17 +0100 |
| commit | 342fe98c34311969950fa58a840fd0b95a16c9dd (patch) | |
| tree | fd6bc1c0b163c831f55bb9aa814571d605105005 /tools/perf/scripts/python/bin | |
| parent | 486c3d06b90240860e99686d29ed9f15637dc314 (diff) | |
sched: Lift cgroup update locking to core to prevent CFS/SCX divergence
Concurrent writes to cgroup control files (such as cpu.shares or
cpu.weight) can lead to state divergence between CFS and SCX.
For instance, in cpu_shares_write_u64(), the CFS update is serialized
by shares_mutex (internal to fair.c), but this lock is dropped before
scx_group_set_weight() is called. The latter only acquires a read
semaphore (scx_cgroup_ops_rwsem), allowing multiple threads to evaluate
and act on the sched_ext update concurrently.
This serialization gap allows concurrent writes to interleave.
As a result, the recorded state in CFS, the SCX internal bookkeeping
(e.g., tg->scx.weight), and the BPF scheduler itself can end up operating
on completely distinct parameters (pairwise distinct values).
Similar races are present in tg_set_bandwidth(), cpu_idle_write_s64(),
cpu_weight_write_u64(), and cpu_weight_nice_write_s64().
Fix this by moving the CFS locking up into the core layer in
`kernel/sched/core.c`. By acquiring these locks directly in the core
write handlers, both the CFS and SCX callbacks are executed atomically
under the same lock.
Fixes: 819513666966 ("sched_ext: Add cgroup support")
Signed-off-by: Michal Blaszczyk <michalblk@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://patch.msgid.link/20261110151857.1864222-1-michalblk@google.com
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions
