cgroup: Implicit unit_invalidate_cgroup_members_masks
Merge members mask invalidation into unit_add_siblings_to_cgroup_realize_queue, this way unit_realize_cgroup needn't be called with members mask invalidation. We have to retain the members mask invalidation in unit_load -- although active units would have cgroups (re)realized (unit_load queues for realization), the realization would happen with potentially stale mask.
This commit is contained in:
@@ -2319,6 +2319,8 @@ void unit_add_siblings_to_cgroup_realize_queue(Unit *u) {
|
||||
|
||||
/* This adds the path from the specified unit to root slice to the queue and siblings at each level.
|
||||
* The unit itself is excluded (assuming it's handled separately).
|
||||
* The function must invalidate cgroup_members_mask of all ancestors in order to calculate up to date
|
||||
* masks.
|
||||
*
|
||||
* Propagation of realization "side-ways" (i.e. towards siblings) is relevant on cgroup-v1 where
|
||||
* scheduling becomes very weird if two units that own processes reside in the same slice, but one is
|
||||
@@ -2333,6 +2335,9 @@ void unit_add_siblings_to_cgroup_realize_queue(Unit *u) {
|
||||
Unit *m;
|
||||
void *v;
|
||||
|
||||
/* Children of slice likely changed when we're called */
|
||||
slice->cgroup_members_mask_valid = false;
|
||||
|
||||
HASHMAP_FOREACH_KEY(v, m, slice->dependencies[UNIT_BEFORE], i) {
|
||||
/* Skip units that have a dependency on the slice but aren't actually in it. */
|
||||
if (UNIT_DEREF(m->slice) != slice)
|
||||
|
||||
@@ -149,7 +149,6 @@ int bus_mount_set_property(
|
||||
int bus_mount_commit_properties(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
unit_invalidate_cgroup_members_masks(u);
|
||||
unit_realize_cgroup(u);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -190,7 +190,6 @@ int bus_scope_set_property(
|
||||
int bus_scope_commit_properties(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
unit_invalidate_cgroup_members_masks(u);
|
||||
unit_realize_cgroup(u);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -457,7 +457,6 @@ int bus_service_set_property(
|
||||
int bus_service_commit_properties(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
unit_invalidate_cgroup_members_masks(u);
|
||||
unit_realize_cgroup(u);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -28,7 +28,6 @@ int bus_slice_set_property(
|
||||
int bus_slice_commit_properties(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
unit_invalidate_cgroup_members_masks(u);
|
||||
unit_realize_cgroup(u);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -469,7 +469,6 @@ int bus_socket_set_property(
|
||||
int bus_socket_commit_properties(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
unit_invalidate_cgroup_members_masks(u);
|
||||
unit_realize_cgroup(u);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -70,7 +70,6 @@ int bus_swap_set_property(
|
||||
int bus_swap_commit_properties(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
unit_invalidate_cgroup_members_masks(u);
|
||||
unit_realize_cgroup(u);
|
||||
|
||||
return 0;
|
||||
|
||||
+1
-3
@@ -664,10 +664,8 @@ void unit_free(Unit *u) {
|
||||
/* A unit is being dropped from the tree, make sure our siblings and ancestor slices are realized
|
||||
* properly. Do this after we detach the unit from slice tree in order to eliminate its effect on
|
||||
* controller masks. */
|
||||
if (UNIT_ISSET(u->slice)) {
|
||||
unit_invalidate_cgroup_members_masks(UNIT_DEREF(u->slice));
|
||||
if (UNIT_ISSET(u->slice))
|
||||
unit_add_siblings_to_cgroup_realize_queue(u);
|
||||
}
|
||||
|
||||
if (u->on_console)
|
||||
manager_unref_console(u->manager);
|
||||
|
||||
Reference in New Issue
Block a user