]> git.ipfire.org Git - thirdparty/systemd.git/commit
cgroup: be more careful with which controllers we can enable/disable on a cgroup
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Nov 2018 20:45:33 +0000 (21:45 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 12:41:37 +0000 (13:41 +0100)
commit27adcc973771a998433635672e2eee0a4489b8a4
treee29608991c58f11835aaf1c5f09d0fa5338e421b
parent94f344fb03101273471eeaa8c821a657255fd076
cgroup: be more careful with which controllers we can enable/disable on a cgroup

This changes cg_enable_everywhere() to return which controllers are
enabled for the specified cgroup. This information is then used to
correctly track the enablement mask currently in effect for a unit.
Moreover, when we try to turn off a controller, and this works, then
this is indicates that the parent unit might succesfully turn it off
now, too as our unit might have kept it busy.

So far, when realizing cgroups, i.e. when syncing up the kernel
representation of relevant cgroups with our own idea we would strictly
work from the root to the leaves. This is generally a good approach, as
when controllers are enabled this has to happen in root-to-leaves order.
However, when controllers are disabled this has to happen in the
opposite order: in leaves-to-root order (this is because controllers can
only be enabled in a child if it is already enabled in the parent, and
if it shall be disabled in the parent then it has to be disabled in the
child first, otherwise it is considered busy when it is attempted to
remove it in the parent).

To make things complicated when invalidating a unit's cgroup membershup
systemd can actually turn off some controllers previously turned on at
the very same time as it turns on other controllers previously turned
off. In such a case we have to work up leaves-to-root *and*
root-to-leaves right after each other. With this patch this is
implemented: we still generally operate root-to-leaves, but as soon as
we noticed we successfully turned off a controller previously turned on
for a cgroup we'll re-enqueue the cgroup realization for all parents of
a unit, thus implementing leaves-to-root where necessary.
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/core/cgroup.c
src/core/cgroup.h
src/nspawn/nspawn-cgroup.c