diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-05 13:50:28 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-05 20:53:47 +0100 |
commit | f7d2991539635b25ab1005887e1502dd8b98f18d (patch) | |
tree | 4014a8d334efa21fb6068887e8d8aec1eb1587f6 /src/core/cgroup.h | |
parent | c631c3d6a340c13adf05dc9b06bd7bd566bd6c9e (diff) | |
download | systemd-f7d2991539635b25ab1005887e1502dd8b98f18d.tar.gz |
core: make TasksMax a partially dynamic property
TasksMax= and DefaultTasksMax= can be specified as percentages. We don't
actually document of what the percentage is relative to, but the implementation
uses the smallest of /proc/sys/kernel/pid_max, /proc/sys/kernel/threads-max,
and /sys/fs/cgroup/pids.max (when present). When the value is a percentage,
we immediately convert it to an absolute value. If the limit later changes
(which can happen e.g. when systemd-sysctl runs), the absolute value becomes
outdated.
So let's store either the percentage or absolute value, whatever was specified,
and only convert to an absolute value when the value is used. For example, when
starting a unit, the absolute value will be calculated when the cgroup for
the unit is created.
Fixes #13419.
Diffstat (limited to 'src/core/cgroup.h')
-rw-r--r-- | src/core/cgroup.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/core/cgroup.h b/src/core/cgroup.h index a66c702125..8f7d19ad4f 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -9,6 +9,19 @@ #include "list.h" #include "time-util.h" +typedef struct TasksMax { + /* If scale == 0, just use value; otherwise, value / scale. + * See tasks_max_scale(). */ + uint64_t value; + uint64_t scale; +} TasksMax; + +static inline bool tasks_max_isset(const TasksMax *tasks_max) { + return tasks_max->value != CGROUP_LIMIT_MAX || tasks_max->scale != 0; +} + +uint64_t tasks_max_scale(const TasksMax *tasks_max); + typedef struct CGroupContext CGroupContext; typedef struct CGroupDeviceAllow CGroupDeviceAllow; typedef struct CGroupIODeviceWeight CGroupIODeviceWeight; @@ -136,7 +149,7 @@ struct CGroupContext { LIST_HEAD(CGroupDeviceAllow, device_allow); /* Common */ - uint64_t tasks_max; + TasksMax tasks_max; }; /* Used when querying IP accounting data */ |