]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched_ext: Use cgroup_lock/unlock() to synchronize against cgroup operations
authorTejun Heo <tj@kernel.org>
Wed, 3 Sep 2025 21:36:07 +0000 (11:36 -1000)
committerTejun Heo <tj@kernel.org>
Wed, 3 Sep 2025 21:36:07 +0000 (11:36 -1000)
commita5bd6ba30b3364354269b81ac55c2edca9a96d6d
tree14d4a1faba02b17d3c163d646a1eda88d0e5ac0f
parentbcb7c2305682c77a8bfdbfe37106b314ac10110f
sched_ext: Use cgroup_lock/unlock() to synchronize against cgroup operations

SCX hooks into CPU cgroup controller operations and read-locks
scx_cgroup_rwsem to exclude them while enabling and disable schedulers.
While this works, it's unnecessarily complicated given that
cgroup_[un]lock() are available and thus the cgroup operations can be locked
out that way.

Drop scx_cgroup_rwsem locking from the tg on/offline and cgroup [can_]attach
operations. Instead, grab cgroup_lock() from scx_cgroup_lock(). Drop
scx_cgroup_finish_attach() which is no longer necessary. Drop the now
unnecessary rcu locking and css ref bumping in scx_cgroup_init() and
scx_cgroup_exit().

As scx_cgroup_set_weight/bandwidth() paths aren't protected by
cgroup_lock(), rename scx_cgroup_rwsem to scx_cgroup_ops_rwsem and retain
the locking there.

This is overall simpler and will also allow enable/disable paths to
synchronize against cgroup changes independent of the CPU controller.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/core.c
kernel/sched/ext.c
kernel/sched/ext.h