Skip to content

CPUQuota does not imply CPUAccounting in systemd-run #9647

@ghost

Description

systemd version the issue has been seen with
239-5 in Debian testing

Used distribution
Debian testing

Expected behaviour you didn't see

Assume the unified cgroup hierarchy.
systemd-run --user --scope --unit=foo -p "CPUQuota=50%" /bin/bash implies CPUAccounting as written in the manpage of systemd.resource-control, like

$ systemctl --user status -l foo.scope
● foo.scope - /bin/bash
   Loaded: loaded (/run/user/1000/systemd/transient/foo.scope; transient)
Transient: yes
   Active: active (running) since Wed 2018-07-18 19:35:32 UTC; 17s ago
    Tasks: 2 (limit: 2365)
   Memory: 2.3M
      CPU: 24ms
   CGroup: /user.slice/user-1000.slice/user@1000.service/foo.scope
           ├─401 /bin/bash
           └─405 systemctl --user status -l foo.scope

Unexpected behaviour you saw

$ systemd-run --user --scope --unit=foo -p "CPUQuota=50%" /bin/bash
Running scope as unit: foo.scope
$ cat /sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/foo.scope/cpu.max
50000 100000

CPUQuota is functioning as requested.

$ systemctl --user show  foo.scope | grep CPU
CPUUsageNSec=[not set]
CPUAccounting=no
CPUWeight=[not set]
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=500ms

CPUAccounting is not implied?! Actually,

$ systemctl --user status -l foo.scope
● foo.scope - /bin/bash
   Loaded: loaded (/run/user/1000/systemd/transient/foo.scope; transient)
Transient: yes
   Active: active (running) since Wed 2018-07-18 19:36:27 UTC; 1min 11s ago
    Tasks: 2 (limit: 2365)
   Memory: 2.5M
   CGroup: /user.slice/user-1000.slice/user@1000.service/foo.scope
           ├─406 /bin/bash
           └─413 systemctl --user status -l foo.scope

CPU accounting information is not shown above. I am happy with the current behavior and suggest updating the documentation.

Steps to reproduce the problem

See above. It is observed on a Debian testing virtual machine with the workaround to systemd-run resource control issue. Systemd-run resource control does not work on a plain Debian testing installation as far as I see.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions