]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
cgroup: reduce dependency on cgroup_mutex
authorShakeel Butt <shakeelb@google.com>
Mon, 25 Oct 2021 06:19:14 +0000 (23:19 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 14 Nov 2022 10:25:21 +0000 (11:25 +0100)
commit45ae8be540ff9473cd24f89574eed2089aa11c4f
tree507298df9b3aaef0cc4cb1c414eba32632a87a86
parent3e0fd55f982e589028318d8d9365d3c19a40a805
cgroup: reduce dependency on cgroup_mutex

BugLink: https://bugs.launchpad.net/bugs/1995517
[ Upstream commit be288169712f3dea0bc6b50c00b3ab53d85f1435 ]

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>
Stable-dep-of: df02452f3df0 ("cgroup: cgroup_get_from_id() must check the looked-up kn is a directory")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
kernel/cgroup/cgroup.c