]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: call cg_all_unified() right before using the result
authorLennart Poettering <lennart@poettering.net>
Mon, 10 Dec 2018 15:08:13 +0000 (16:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 10 Dec 2018 15:09:41 +0000 (16:09 +0100)
Let's not query it before we actually need it.

src/core/cgroup.c

index 2dd53191e0744b5e0b3e4b0bf50820b2a3973ebe..75085607d4663270364636adfe50562000b81ab0 100644 (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;