Skip to content

Applying a mask with only one of joined cgroup controllers results in being placed in the wrong cgroup #10580

@cdown

Description

@cdown

systemd version the issue has been seen with

HEAD

Used distribution

Arch Linux

Expected behaviour you didn't see

If JoinController=x,y is set and we set CGROUP_MASK_X for a unit, the unit is still added to the x,y hierarchy with its own service cgroup.

Unexpected behaviour you saw

If JoinController=x,y is set and we set CGROUP_MASK_X for a unit, the unit gets put in the wrong cgroup in the x,y hierarchy (its slice parent).

Steps to reproduce the problem

See #10507 (comment) for where this was found:

  1. Use hybrid hierarchy
  2. Set JoinControllers=cpu,cpuacct (part of the default)
  3. Change systemd code so it only applies CGROUP_MASK_CPU for CPUShares in src/core/cgroup.c in cgroup_context_has_cpu_weight/cgroup_context_has_cpu_shares check at the top of cgroup_context_get_mask
  4. systemd-run -p CPUShares=100 sleep infinity
  5. Look at cgroups for sleep infinity process (see cpu,cpuacct hierarchy where we've been placed in parent slice):
12:pids:/system.slice/run-r2969b148d2cd4305989b0573144eb674.service
11:blkio:/
10:cpu,cpuacct:/system.slice
9:devices:/system.slice/run-r2969b148d2cd4305989b0573144eb674.service
8:net_cls,net_prio:/
7:freezer:/
6:hugetlb:/
5:cpuset:/
4:rdma:/
3:memory:/system.slice/run-r2969b148d2cd4305989b0573144eb674.service
2:perf_event:/
1:name=systemd:/system.slice/run-r2969b148d2cd4305989b0573144eb674.service
0::/system.slice/run-r2969b148d2cd4305989b0573144eb674.service

My guess is that this deficiency went unnoticed because we only usually apply cpuacct and cpu together in old code, and net_cls/net_prio was not so commonly exercised independently either.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions