]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cgroup: reduce dependency on cgroup_mutex
authorShakeel Butt <shakeelb@google.com>
Mon, 25 Oct 2021 06:19:14 +0000 (23:19 -0700)
committerTejun Heo <tj@kernel.org>
Mon, 25 Oct 2021 17:23:31 +0000 (07:23 -1000)
commitbe288169712f3dea0bc6b50c00b3ab53d85f1435
tree1a92e683510d3ea9ba8aa49535d67f96893149fd
parent0061270307f2ad5fa01db1ac5f1da0e83410adaf
cgroup: reduce dependency on cgroup_mutex

Currently cgroup_get_from_path() and cgroup_get_from_id() grab
cgroup_mutex before traversing the default hierarchy to find the
kernfs_node corresponding to the path/id and then extract the linked
cgroup. Since cgroup_mutex is still held, it is guaranteed that the
cgroup will be alive and the reference can be taken on it.

However similar guarantee can be provided without depending on the
cgroup_mutex and potentially reducing avenues of cgroup_mutex contentions.
The kernfs_node's priv pointer is RCU protected pointer and with just
rcu read lock we can grab the reference on the cgroup without
cgroup_mutex. So, remove cgroup_mutex from them.

Signed-off-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup.c