summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-09 19:05:59 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:59:09 +0200
commit581473bcb149098f94f684c5f526a2ce932a7df1 (patch)
tree69a94ea4e959b408d841b6213968c7f1cf4faa55
parentfa4505314d65df4bd778543ea3753d6efd696ca1 (diff)
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.
-rw-r--r--src/core/cgroup.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 51f41e03b..c5ca9947e 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -2355,6 +2355,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;
@@ -2386,13 +2390,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;
@@ -2413,6 +2417,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;