]> git.ipfire.org Git - thirdparty/systemd.git/commit
cgroup: drastically simplify caching of cgroups members mask
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 00:07:34 +0000 (01:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 12:41:37 +0000 (13:41 +0100)
commit5af8805872809e6de4cc4d9495cb1a904772ab4e
tree9439dd6aa914bd1917d2a4db2e9dbf8b77c55148
parent8a0d538815b72563eb227fa21a67e78f5b290bfe
cgroup: drastically simplify caching of cgroups members mask

Previously we tried to be smart: when a new unit appeared and it only
added controllers to the cgroup mask we'd update the cached members mask
in all parents by ORing in the controller flags in their cached values.
Unfortunately this was quite broken, as we missed some conditions when
this cache had to be reset (for example, when a unit got unloaded),
moreover the optimization doesn't work when a controller is removed
anyway (as in that case there's no other way for the parent to iterate
though all children if any other, remaining child unit still needs it).
Hence, let's simplify the logic substantially: instead of updating the
cache on the right events (which we didn't get right), let's simply
invalidate the cache, and generate it lazily when we encounter it later.
This should actually result in better behaviour as we don't have to
calculate the new members mask for a whole subtree whever we have the
suspicion something changed, but can delay it to the point where we
actually need the members mask.

This allows us to simplify things quite a bit, which is good, since
validating this cache for correctness is hard enough.

Fixes: #9512
src/core/cgroup.c
src/core/cgroup.h
src/core/dbus-mount.c
src/core/dbus-scope.c
src/core/dbus-service.c
src/core/dbus-slice.c
src/core/dbus-socket.c
src/core/dbus-swap.c
src/core/unit.c
src/core/unit.h