From: Lennart Poettering Date: Mon, 10 Dec 2018 15:08:13 +0000 (+0100) Subject: cgroup: call cg_all_unified() right before using the result X-Git-Tag: v240~96^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92a993041a07149a24f20d5f818e9718339fac30;p=thirdparty%2Fsystemd.git cgroup: call cg_all_unified() right before using the result Let's not query it before we actually need it. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 2dd53191e07..75085607d46 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -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;