cgroup: call cg_all_unified() right before using the result

Let's not query it before we actually need it.
This commit is contained in:
Lennart Poettering 2018-12-10 16:08:13 +01:00
parent 8f3fd07ac0
commit 92a993041a

View file

@ -2844,14 +2844,13 @@ static int unit_get_cpu_usage_raw(Unit *u, nsec_t *ret) {
if (unit_has_host_root_cgroup(u)) if (unit_has_host_root_cgroup(u))
return procfs_cpu_get_usage(ret); return procfs_cpu_get_usage(ret);
r = cg_all_unified();
if (r < 0)
return r;
/* Requisite controllers for CPU accounting are not enabled */ /* Requisite controllers for CPU accounting are not enabled */
if ((get_cpu_accounting_mask() & ~u->cgroup_realized_mask) != 0) if ((get_cpu_accounting_mask() & ~u->cgroup_realized_mask) != 0)
return -ENODATA; return -ENODATA;
r = cg_all_unified();
if (r < 0)
return r;
if (r > 0) { if (r > 0) {
_cleanup_free_ char *val = NULL; _cleanup_free_ char *val = NULL;
uint64_t us; uint64_t us;