summaryrefslogtreecommitdiff
path: root/src/cgtop
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-09 17:34:31 +0100
committerLennart Poettering <lennart@poettering.net>2018-02-09 17:34:31 +0100
commit744c39ff7e2646bcf90b9710b89e4769f8820025 (patch)
treee739107ea1cb8ef5f4cc7d537d3b3f10f9293cbb /src/cgtop
parenta04fcf17badf8ee2ed549bf99c4e5a37e0f7aecf (diff)
downloadsystemd-744c39ff7e2646bcf90b9710b89e4769f8820025.tar.gz
cgtop: hook up new /proc based emulation code for root cgroup memory/cpu stats
Let's make this work.
Diffstat (limited to 'src/cgtop')
-rw-r--r--src/cgtop/cgtop.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 27e713fd93..ccd5fef0af 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -252,7 +252,11 @@ static int process(
uint64_t new_usage;
nsec_t timestamp;
- if (all_unified) {
+ if (is_root_cgroup(path)) {
+ r = procfs_cpu_get_usage(&new_usage);
+ if (r < 0)
+ return r;
+ } else if (all_unified) {
const char *keys[] = { "usage_usec", NULL };
_cleanup_free_ char *val = NULL;
@@ -310,24 +314,31 @@ static int process(
g->cpu_iteration = iteration;
} else if (streq(controller, "memory")) {
- _cleanup_free_ char *p = NULL, *v = NULL;
- if (all_unified)
- r = cg_get_path(controller, path, "memory.current", &p);
- else
- r = cg_get_path(controller, path, "memory.usage_in_bytes", &p);
- if (r < 0)
- return r;
+ if (is_root_cgroup(path)) {
+ r = procfs_memory_get_current(&g->memory);
+ if (r < 0)
+ return r;
+ } else {
+ _cleanup_free_ char *p = NULL, *v = NULL;
- r = read_one_line_file(p, &v);
- if (r == -ENOENT)
- return 0;
- if (r < 0)
- return r;
+ if (all_unified)
+ r = cg_get_path(controller, path, "memory.current", &p);
+ else
+ r = cg_get_path(controller, path, "memory.usage_in_bytes", &p);
+ if (r < 0)
+ return r;
- r = safe_atou64(v, &g->memory);
- if (r < 0)
- return r;
+ r = read_one_line_file(p, &v);
+ if (r == -ENOENT)
+ return 0;
+ if (r < 0)
+ return r;
+
+ r = safe_atou64(v, &g->memory);
+ if (r < 0)
+ return r;
+ }
if (g->memory > 0)
g->memory_valid = true;