From: Lennart Poettering Date: Fri, 9 Feb 2018 18:05:59 +0000 (+0100) Subject: core: hook up /proc queries for the root slice, too X-Git-Tag: v238~33^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1f73aa0021417c8ba70c78d16d6f68d3032db4ac;p=thirdparty%2Fsystemd.git core: hook up /proc queries for the root slice, too Do what we already prepped in cgtop for the root slice in PID 1 too: consult /proc for the data we need. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 8b760a98884..924285de827 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -2296,6 +2296,10 @@ int unit_get_memory_current(Unit *u, uint64_t *ret) { if (!u->cgroup_path) return -ENODATA; + /* The root cgroup doesn't expose this information, let's get it from /proc instead */ + if (unit_has_root_cgroup(u)) + return procfs_memory_get_current(ret); + if ((u->cgroup_realized_mask & CGROUP_MASK_MEMORY) == 0) return -ENODATA; @@ -2327,13 +2331,13 @@ int unit_get_tasks_current(Unit *u, uint64_t *ret) { if (!u->cgroup_path) return -ENODATA; - if ((u->cgroup_realized_mask & CGROUP_MASK_PIDS) == 0) - return -ENODATA; - /* The root cgroup doesn't expose this information, let's get it from /proc instead */ if (unit_has_root_cgroup(u)) return procfs_tasks_get_current(ret); + if ((u->cgroup_realized_mask & CGROUP_MASK_PIDS) == 0) + return -ENODATA; + r = cg_get_attribute("pids", u->cgroup_path, "pids.current", &v); if (r == -ENOENT) return -ENODATA; @@ -2354,6 +2358,10 @@ static int unit_get_cpu_usage_raw(Unit *u, nsec_t *ret) { if (!u->cgroup_path) return -ENODATA; + /* The root cgroup doesn't expose this information, let's get it from /proc instead */ + if (unit_has_root_cgroup(u)) + return procfs_cpu_get_usage(ret); + r = cg_all_unified(); if (r < 0) return r;