]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
cgroup: protect cgroup->nr_(dying_)descendants by css_set_lock
authorRoman Gushchin <guro@fb.com>
Fri, 19 Apr 2019 17:03:03 +0000 (10:03 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit8d747b13c98eaf646bf491b9faa9dfe4b3462aea
tree9c536cb9c61611edb76f2766dcf8b61ea5b27667
parent5eba74d834023c0f05a25c1a00db1310cc2dc242
cgroup: protect cgroup->nr_(dying_)descendants by css_set_lock

BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit 4dcabece4c3a9f9522127be12cc12cc120399b2f ]

The number of descendant cgroups and the number of dying
descendant cgroups are currently synchronized using the cgroup_mutex.

The number of descendant cgroups will be required by the cgroup v2
freezer, which will use it to determine if a cgroup is frozen
(depending on total number of descendants and number of frozen
descendants). It's not always acceptable to grab the cgroup_mutex,
especially from quite hot paths (e.g. exit()).

To avoid this, let's additionally synchronize these counters using
the css_set_lock.

So, it's safe to read these counters with either cgroup_mutex or
css_set_lock locked, and for changing both locks should be acquired.

Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: kernel-team@fb.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
include/linux/cgroup-defs.h
kernel/cgroup/cgroup.c