summaryrefslogtreecommitdiff
path: root/src/core/cgroup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-10-25 20:46:01 +0200
committerSven Eden <yamakuzure@gmx.net>2017-10-25 20:46:01 +0200
commitb4644d6fc82c447561ec6208e8c64fb230a7506d (patch)
tree621143c04fdfaf12b6dd5e8a9a61e66d4ce774b3 /src/core/cgroup.c
parent135123f7f1f8ce767fabe73c82f38b45f91db2f2 (diff)
core: track why unit dependencies came to be
This replaces the dependencies Set* objects by Hashmap* objects, where the key is the depending Unit, and the value is a bitmask encoding why the specific dependency was created. The bitmask contains a number of different, defined bits, that indicate why dependencies exist, for example whether they are created due to explicitly configured deps in files, by udev rules or implicitly. Note that memory usage is not increased by this change, even though we store more information, as we manage to encode the bit mask inside the value pointer each Hashmap entry contains. Why this all? When we know how a dependency came to be, we can update dependencies correctly when a configuration source changes but others are left unaltered. Specifically: 1. We can fix UDEV_WANTS dependency generation: so far we kept adding dependencies configured that way, but if a device lost such a dependency we couldn't them again as there was no scheme for removing of dependencies in place. 2. We can implement "pin-pointed" reload of unit files. If we know what dependencies were created as result of configuration in a unit file, then we know what to flush out when we want to reload it. 3. It's useful for debugging: "elogind-analyze dump" now shows this information, helping substantially with understanding how elogind's dependency tree came to be the way it came to be.
Diffstat (limited to 'src/core/cgroup.c')
-rw-r--r--src/core/cgroup.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index dd6faf493..0cd1d06b6 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -1097,10 +1097,11 @@ CGroupMask unit_get_members_mask(Unit *u) {
u->cgroup_members_mask = 0;
if (u->type == UNIT_SLICE) {
+ void *v;
Unit *member;
Iterator i;
- SET_FOREACH(member, u->dependencies[UNIT_BEFORE], i) {
+ HASHMAP_FOREACH_KEY(v, member, u->dependencies[UNIT_BEFORE], i) {
if (member == u)
continue;
@@ -1577,8 +1578,9 @@ static void unit_add_siblings_to_cgroup_realize_queue(Unit *u) {
while ((slice = UNIT_DEREF(u->slice))) {
Iterator i;
Unit *m;
+ void *v;
- SET_FOREACH(m, slice->dependencies[UNIT_BEFORE], i) {
+ HASHMAP_FOREACH_KEY(v, m, u->dependencies[UNIT_BEFORE], i) {
if (m == u)
continue;
@@ -2484,8 +2486,9 @@ void unit_invalidate_cgroup_bpf(Unit *u) {
if (u->type == UNIT_SLICE) {
Unit *member;
Iterator i;
+ void *v;
- SET_FOREACH(member, u->dependencies[UNIT_BEFORE], i) {
+ HASHMAP_FOREACH_KEY(v, member, u->dependencies[UNIT_BEFORE], i) {
if (member == u)
continue;