cgroup: when querying the number of tasks in the root slice use the pid_max sysctl

The root cgroup doesn't expose and properties in the "pids" cgroup
controller, hence we need to get the data from somewhere else.
This commit is contained in:
Lennart Poettering 2018-01-17 15:39:39 +01:00
parent f3725e64fe
commit c36a69f4cd
1 changed files with 5 additions and 0 deletions

View 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"
@ -2271,6 +2272,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;