chiark / gitweb /
cgroup: when querying the number of tasks in the root slice use the pid_max sysctl
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jan 2018 14:39:39 +0000 (15:39 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:17 +0000 (07:50 +0200)
The root cgroup doesn't expose and properties in the "pids" cgroup
controller, hence we need to get the data from somewhere else.

src/core/cgroup.c

index 2e70aa79ad75e5f48fe33cc1cc325b0314599113..153a0dda804241e65025484bfee61360c4a1aaff 100644 (file)
@@ -32,6 +32,7 @@
 #include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"
+//#include "procfs-util.h"
 //#include "special.h"
 #include "stdio-util.h"
 #include "string-table.h"
@@ -2330,6 +2331,10 @@ int unit_get_tasks_current(Unit *u, uint64_t *ret) {
         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);
+
         r = cg_get_attribute("pids", u->cgroup_path, "pids.current", &v);
         if (r == -ENOENT)
                 return -ENODATA;