Running command under systemd slice works for root, but not user
2
votes
0
answers
1109
views
I'm trying to execute a command under some resource limits.
This correctly limits
my-bin
to just 1 CPU core. I'm able to verify with htop
.
$ sudo systemd-run -p AllowedCPUs=0 -- ./my-bin
However, this doesn't work. htop
shows all cores active.
$ systemd-run --user -p AllowedCPUs=0 -- ./my-bin
Seems like my user slice is under the correct controllers. I set Delegate=yes
for my user slice. I followed this [guide](https://wiki.archlinux.org/index.php/cgroups#Switching_to_cgroups_v2) .
$ cat /sys/fs/cgroup/user.slice/user-1000.slice/cgroup.controllers
cpuset cpu io memory pids
Here's my version info.
$ systemctl --version
systemd 247 (247.2-1-arch)
+PAM +AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYP
T +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2
default-hierarchy=hybrid
Is there some configuration I missed? Or am I misunderstanding how this is supposed to work?
Asked by 425nesp
(456 rep)
Jan 21, 2021, 09:11 PM