I am using systemd-nspawn(systemd version 237) in Yocto's embedded Linux environment.

This is the content of /etc/systemd/system/systemd-nspawn\@.service.d/override.conf file

ExecStart=/usr/bin/systemd-nspawn --quiet --boot --link-journal=try-guest --machine=%i -n --property=CPUQuota=10%

I am trying to load the CPU with "sha1sum /dev/zero &" or "for i in 1 2 3 4; do while : ; do : ; done & done" inside the container but the top command on host shows that always they are at 50% CPU usage altogether(4 sh processes and one sha1sum process, if only sha1sum process is started, it alone uses 50% if not 10% each)

I am unable to understand if there is any other setting where this 50% limitation is coming from? And why CPU quota is not effective


Since cgroup v2 is recommended now, I suggest to try the same command with cgroup v2. To do this, add systemd.unified_cgroup_hierarchy=1 to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, run update-grub, and reboot Linux. I hope cgroup v2 gives better CPU control to you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.