5af8805872
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
36 lines
772 B
C
36 lines
772 B
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
|
#include "dbus-cgroup.h"
|
|
#include "dbus-slice.h"
|
|
#include "slice.h"
|
|
#include "unit.h"
|
|
|
|
const sd_bus_vtable bus_slice_vtable[] = {
|
|
SD_BUS_VTABLE_START(0),
|
|
SD_BUS_VTABLE_END
|
|
};
|
|
|
|
int bus_slice_set_property(
|
|
Unit *u,
|
|
const char *name,
|
|
sd_bus_message *message,
|
|
UnitWriteFlags flags,
|
|
sd_bus_error *error) {
|
|
|
|
Slice *s = SLICE(u);
|
|
|
|
assert(name);
|
|
assert(u);
|
|
|
|
return bus_cgroup_set_property(u, &s->cgroup_context, name, message, flags, error);
|
|
}
|
|
|
|
int bus_slice_commit_properties(Unit *u) {
|
|
assert(u);
|
|
|
|
unit_invalidate_cgroup_members_masks(u);
|
|
unit_realize_cgroup(u);
|
|
|
|
return 0;
|
|
}
|