cgroup: Make operations on the cgroup root_list RCU safe
authorYafang Shao <laoar.shao@gmail.com>
Sun, 29 Oct 2023 06:14:29 +0000 (06:14 +0000)
committerBen Hutchings <benh@debian.org>
Thu, 3 Oct 2024 21:58:46 +0000 (23:58 +0200)
commitca2bf8193374e2452c756eb80ffdc504f01036aa
treeaedb0695a0ccb58a123c346a2cfb308ba6296eba
parentb00ced6371809f1e503fe216bc3c71a17f2cb501
cgroup: Make operations on the cgroup root_list RCU safe

[ Upstream commit d23b5c577715892c87533b13923306acc6243f93 ]

At present, when we perform operations on the cgroup root_list, we must
hold the cgroup_mutex, which is a relatively heavyweight lock. In reality,
we can make operations on this list RCU-safe, eliminating the need to hold
the cgroup_mutex during traversal. Modifications to the list only occur in
the cgroup root setup and destroy paths, which should be infrequent in a
production environment. In contrast, traversal may occur frequently.
Therefore, making it RCU-safe would be beneficial.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name cgroup-make-operations-on-the-cgroup-root_list-rcu-s.patch
include/linux/cgroup-defs.h
kernel/cgroup/cgroup-internal.h
kernel/cgroup/cgroup.c