Re: [systemd-devel] MemoryLimit for user unit
On So, 12.11.17 18:14, Stefan Schweter (ste...@schweter.it) wrote: > Hi systemd-users, > > I tried to add a memory limit for a user service unit (inspired by [1]), > it looks like: > > [Service] > # > MemoryAccounting=true > MemoryLimit=1G > > Now the problem is that the (user) service consumes more than 1G without > being terminated. Note that on cgroupsv1 delegation of controllers to unprivileged code is not safe and hence systemd won't do it. That means you have to boot in cgroupsv2 mode (i.e. "unified") to get any controller support at all for the user systemd instance. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] MemoryLimit for user unit
On 2017년 11월 13일 09:53, Kai Krakow wrote: > Am Sun, 12 Nov 2017 18:14:38 +0100 > schrieb Stefan Schweter: > >> Hi systemd-users, >> >> I tried to add a memory limit for a user service unit (inspired by >> [1]), it looks like: >> >> [Service] >> # >> MemoryAccounting=true >> MemoryLimit=1G >> >> Now the problem is that the (user) service consumes more than 1G >> without being terminated. > > As far as I could see, this limits the amount of RAM occupied. It > doesn't stop the memory from being swapped out. You need to limit swap > memory, too. Take note that swap accounting may have noticeable > overheads and as such is not enabled by default on many systems. > By this reason, MemorySwapMax= option is introduced. https://github.com/systemd/systemd/pull/3659 Note, MemorySwapLimit= does not exist. Lennard does not want to add more options for legacy cgroup. Further, the swap limit operations different between legacy and unified cgroup. So adding MemorySwapLimit= was not good idea. > >> htop shows a memory consumption of 1.4 GB. The output of >> `systemd-cgtop` is: >> >> Control Group Tasks %CPU Memory >> Input/s Output/s >> / -1.5 >> 1.7G- >> >> /user.slice 460.4 >> 14.3M- >> >> /user.slice/user-1001.slice 460.4 >> 14.2M- >> >> /init.scope 1 - >> 1.4M- >> >> /system.slice >> >> >> So my question is how would MemoryLimit= work for a user unit? > > Maybe you want to apply the limit to a slice? Your output of cgtop > doesn't show any service units... > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] MemoryLimit for user unit
Am Sun, 12 Nov 2017 18:14:38 +0100 schrieb Stefan Schweter: > Hi systemd-users, > > I tried to add a memory limit for a user service unit (inspired by > [1]), it looks like: > > [Service] > # > MemoryAccounting=true > MemoryLimit=1G > > Now the problem is that the (user) service consumes more than 1G > without being terminated. As far as I could see, this limits the amount of RAM occupied. It doesn't stop the memory from being swapped out. You need to limit swap memory, too. Take note that swap accounting may have noticeable overheads and as such is not enabled by default on many systems. > htop shows a memory consumption of 1.4 GB. The output of > `systemd-cgtop` is: > > Control Group Tasks %CPU Memory > Input/s Output/s > / -1.5 > 1.7G- > > /user.slice 460.4 > 14.3M- > > /user.slice/user-1001.slice 460.4 > 14.2M- > > /init.scope 1 - > 1.4M- > > /system.slice > > > So my question is how would MemoryLimit= work for a user unit? Maybe you want to apply the limit to a slice? Your output of cgtop doesn't show any service units... -- Regards, Kai Replies to list-only preferred. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] MemoryLimit for user unit
Hi systemd-users, I tried to add a memory limit for a user service unit (inspired by [1]), it looks like: [Service] # MemoryAccounting=true MemoryLimit=1G Now the problem is that the (user) service consumes more than 1G without being terminated. htop shows a memory consumption of 1.4 GB. The output of `systemd-cgtop` is: Control Group Tasks %CPU Memory Input/s Output/s / -1.5 1.7G- /user.slice 460.414.3M- /user.slice/user-1001.slice 460.414.2M- /init.scope 1 - 1.4M- /system.slice So my question is how would MemoryLimit= work for a user unit? My system is Debian 9 with systemd: $ systemctl --version systemd 232 +PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN Thanks in advance + regards. Stefan [1] http://0pointer.de/blog/projects/resources.html ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel