Sample Header Ad - 728x90

Why isn't this systemd service resource limited when using CPUShares property?

4 votes
1 answer
2506 views
Ok to get my hands dirty with cgroups and systemd, I wrote the most moronic C program I could think of (just a timer and a spinlocking while loop) and named it idiot, which I accompanied with the following idiot.service file in /sys/fs/systemd/system/: [Unit] Description=Idiot - pretty idiotic imo [Service] Type=simple ExecStart=/path/to/idiot User=bruno CPUShares=100 [Install] WantedBy=default.target Then I did sudo systemctl start idiot.service; top | grep idiot, which predictably told me idiot used 100% of CPU. Now, according to link , we should be able to limit the resources of this service by the following: sudo systemctl set-property idiot.service CPUShares=100 sudo systemctl daemon-reload sudo systemctl restart idiot.service which I did, followed by top. But this still tells me that idiot is using 100% of CPU! What am I doing wrong? Note: I also tried adding CPUShares=100 to the unit file, to no avail
Asked by embedded_crysis (337 rep)
Feb 28, 2017, 02:27 PM
Last activity: Jan 5, 2022, 09:14 AM