]> git.baikalelectronics.ru Git - kernel.git/commit
cgroup: Elide write-locking threadgroup_rwsem when updating csses on an empty subtree
authorTejun Heo <tj@kernel.org>
Fri, 15 Jul 2022 04:38:15 +0000 (18:38 -1000)
committerTejun Heo <tj@kernel.org>
Sat, 23 Jul 2022 05:12:37 +0000 (19:12 -1000)
commit9ead8b06a7b4354afcf7cd35cfd087ae89debe8d
treefd0809b98129b438cf7f55e9814349da3b2a8ce3
parenta31a2060b4e7f6a1f07a06b32dcbe4a81d4b7def
cgroup: Elide write-locking threadgroup_rwsem when updating csses on an empty subtree

cgroup_update_dfl_csses() write-lock the threadgroup_rwsem as updating the
csses can trigger process migrations. However, if the subtree doesn't
contain any tasks, there aren't gonna be any cgroup migrations. This
condition can be trivially detected by testing whether
mgctx.preloaded_src_csets is empty. Elide write-locking threadgroup_rwsem if
the subtree is empty.

After this optimization, the usage pattern of creating a cgroup, enabling
the necessary controllers, and then seeding it with CLONE_INTO_CGROUP and
then removing the cgroup after it becomes empty doesn't need to write-lock
threadgroup_rwsem at all.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
kernel/cgroup/cgroup.c