summaryrefslogtreecommitdiffstats
path: root/src/core/cgroup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-15 21:15:19 +0100
committerLennart Poettering <lennart@poettering.net>2018-11-16 14:54:13 +0100
commitfae9bc298ac1dc37021d576c0793800c6e625f89 (patch)
tree911a59050fa7da0c51798851721a766e7e546a68 /src/core/cgroup.c
parentcgroup: add new helper that knows which controllers are mounted together (diff)
downloadsystemd-fae9bc298ac1dc37021d576c0793800c6e625f89.tar.xz
systemd-fae9bc298ac1dc37021d576c0793800c6e625f89.zip
cgroup: when determining which controllers we need, always extend the mask according to cpu/cpuacct joint mounting
Note that for cgroup_context_get_mask() this doesn't actually change much, but it does prepare the ground for #10507 later on.
Diffstat (limited to 'src/core/cgroup.c')
-rw-r--r--src/core/cgroup.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index baa356b32b..45a7581d45 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -1175,13 +1175,15 @@ static void cgroup_context_apply(
CGroupMask cgroup_context_get_mask(CGroupContext *c) {
CGroupMask mask = 0;
- /* Figure out which controllers we need */
+ /* Figure out which controllers we need, based on the cgroup context object */
- if (c->cpu_accounting ||
- cgroup_context_has_cpu_weight(c) ||
+ if (c->cpu_accounting)
+ mask |= CGROUP_MASK_CPUACCT;
+
+ if (cgroup_context_has_cpu_weight(c) ||
cgroup_context_has_cpu_shares(c) ||
c->cpu_quota_per_sec_usec != USEC_INFINITY)
- mask |= CGROUP_MASK_CPUACCT | CGROUP_MASK_CPU;
+ mask |= CGROUP_MASK_CPU;
if (cgroup_context_has_io_config(c) || cgroup_context_has_blockio_config(c))
mask |= CGROUP_MASK_IO | CGROUP_MASK_BLKIO;
@@ -1199,12 +1201,15 @@ CGroupMask cgroup_context_get_mask(CGroupContext *c) {
c->tasks_max != CGROUP_LIMIT_MAX)
mask |= CGROUP_MASK_PIDS;
- return mask;
+ return CGROUP_MASK_EXTEND_JOINED(mask);
}
CGroupMask unit_get_bpf_mask(Unit *u) {
CGroupMask mask = 0;
+ /* Figure out which controllers we need, based on the cgroup context, possibly taking into account children
+ * too. */
+
if (unit_get_needs_bpf_firewall(u))
mask |= CGROUP_MASK_BPF_FIREWALL;
@@ -1243,7 +1248,7 @@ CGroupMask unit_get_delegate_mask(Unit *u) {
}
assert_se(c = unit_get_cgroup_context(u));
- return c->delegate_controllers;
+ return CGROUP_MASK_EXTEND_JOINED(c->delegate_controllers);
}
CGroupMask unit_get_members_mask(Unit *u) {