You are not logged in.

#1 2021-01-22 08:35:09

Registered: 2017-01-17
Posts: 60

sudo systemd-run cgroups work, but systemd-run user cgroups don't

Hello, I'm trying to limit the number of CPU cores my binary has access to. I followed the guide here: … cgroups_v2

I got this to work correctly.

$ sudo systemd-run -p AllowedCPUs=0 -- ./my-bin

I was able to verify that my-bin only uses 1 CPU core by checking in htop.

However, if I try to run as a non-root user, then this doesn't work. I'm able to see all the cores light up in htop.

$ systemd-run --user -p AllowedCPUs=0 -- ./my-bin

The right controllers seem to be enabled.

$ cat /sys/fs/cgroup/user.slice/user-1000.slice/cgroup.controllers    
cpuset cpu io memory pids

I also edited user@1000.service to include Delegate=yes.

This is my systemd version.

$ systemctl --version
systemd 247 (247.2-1-arch)


Board footer

Powered by FluxBB