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
1 changed files with 3 additions and 4 deletions

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))
return procfs_cpu_get_usage(ret);
r = cg_all_unified();
if (r < 0)
return r;
/* Requisite controllers for CPU accounting are not enabled */
if ((get_cpu_accounting_mask() & ~u->cgroup_realized_mask) != 0)
return -ENODATA;
r = cg_all_unified();
if (r < 0)
return r;
if (r > 0) {
_cleanup_free_ char *val = NULL;
uint64_t us;