mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-24 18:56:59 +07:00
cgroup: immediately remove all cgroups which run empty
Some controllers have scaling problems when many empty cgroups exist. Hence, as soon as we get a notification that a cgroup is empty, delete it. This is also nice to keep the systemd-cgls output short.
This commit is contained in:
parent
263653e103
commit
353fa6a21a
12
src/cgroup.c
12
src/cgroup.c
@ -363,7 +363,8 @@ int cgroup_notify_empty(Manager *m, const char *group) {
|
|||||||
assert(m);
|
assert(m);
|
||||||
assert(group);
|
assert(group);
|
||||||
|
|
||||||
if (!(l = hashmap_get(m->cgroup_bondings, group)))
|
l = hashmap_get(m->cgroup_bondings, group);
|
||||||
|
if (!l)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
LIST_FOREACH(by_path, b, l) {
|
LIST_FOREACH(by_path, b, l) {
|
||||||
@ -372,7 +373,8 @@ int cgroup_notify_empty(Manager *m, const char *group) {
|
|||||||
if (!b->unit)
|
if (!b->unit)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((t = cgroup_bonding_is_empty_list(b)) < 0) {
|
t = cgroup_bonding_is_empty_list(b);
|
||||||
|
if (t < 0) {
|
||||||
|
|
||||||
/* If we don't know, we don't know */
|
/* If we don't know, we don't know */
|
||||||
if (t != -EAGAIN)
|
if (t != -EAGAIN)
|
||||||
@ -381,9 +383,13 @@ int cgroup_notify_empty(Manager *m, const char *group) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t > 0)
|
if (t > 0) {
|
||||||
|
/* If it is empty, let's delete it */
|
||||||
|
cgroup_bonding_trim_list(b->unit->meta.cgroup_bondings, true);
|
||||||
|
|
||||||
if (UNIT_VTABLE(b->unit)->cgroup_notify_empty)
|
if (UNIT_VTABLE(b->unit)->cgroup_notify_empty)
|
||||||
UNIT_VTABLE(b->unit)->cgroup_notify_empty(b->unit);
|
UNIT_VTABLE(b->unit)->cgroup_notify_empty(b->unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user