You are not logged in.

#1 2019-01-21 20:16:17

u8sand
Member
Registered: 2012-08-15
Posts: 24

`systemd --user -p CPUQuota=10%` not honored?

I'm trying to restrict the CPU usage of a misbehaving userspace daemon using systemd's CPUQuota directive, but somehow it doesn't seem to be respected.

One thing I did to test this in general was the following:

systemd-run -p CPUQuota=25% --slice=stress -- stress -c 12
systemd-run --user -p CPUQuota=25% --slice=stress -- stress -c 12

Where the former works as expected using only 25% of my CPU; the latter uses all 100% of my user.slice quota.

According to `man systemd.resource-control` this might have to do with cgroup-v1/v2. As such I tried to set up cgroup-v2 through a linux kernel parameter `systemd.unified_cgroup_hierarchy=1`.

I've also tried setting `CPUAccounting=yes` explicitly on both the user-slice and the service in question to no avail.

Frankly I'm not too familiar with cgroups to properly diagnose this issue, and no journal/systemd errors are being reported--the option is just basically getting ignored.
When I do systemctl show <service> I get:

...
ControlGroup=/user.slice/user-1000.slice/user@1000.service/the.service
MemoryCurrent=159780864
CPUUsageNSec=74053245000
Delegate=no
CPUAccounting=yes
CPUWeight=1
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=20ms
...
LimitCPU=infinity
LimitCPUSoft=infinity
...

Would these LimitCPU directives (which seem to rely on ulimit) work as an alternative? What am I doing wrong? Or is this a bug with cgroups and systemd --user?

Offline

Board footer

Powered by FluxBB