[systemd-devel] CPU usage limit to systemd-nspawn container is not working
Lennart Poettering
lennart at poettering.net
Wed Jul 18 19:15:51 UTC 2018
On Mi, 18.07.18 19:10, patlollamahipal at yahoo.co.in (patlollamahipal at yahoo.co.in) wrote:
> Hi All,I am using systemd-nspawn(systemd version 237) to create a container in Yocto's embedded Linux environment on Cortex-A53
>
> Content of the file
>
>
> /etc/systemd/system/systemd-nspawn\@.service.d/override.conf
>
> is[Service]ExecStart=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
> passed to systemd-nspawn is not effective?I also tried
> with /etc/systemd/system/systemd-nspawn at .service.d/cpu.conf, still
> the same result but if I pass MemoryMax=50M, process gets killed if
> i try to use more than 50M in total inside the container.If anyone
> knows please help. Thank
nspawn's --property= is only relevant if nspawn allocates a scope unit
for the container. But that's not what systemd-nspawn at .service is for:
in that case nspawn simply makes use of the service unit it is already
run in. This is documented in the man page, if you have a look.
Or in other words: in your unit file drop-in just place CPUQuota=
directly in your [Service] Section:
[Service]
CPUQuota=10%
And do not make any changes to ExecStart=.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list