
On Sun, May 14, 2017 at 12:24:21PM +1000, Russell Coker via luv-main wrote:
When you use systemd the systemd-logind creates a new cgroup named user-$UID.slice. ... I've set the max_usage_in_bytes to 100M (see the above Red Hat URL for an explanation of this). But it doesn't seem to work, I've written a test program that allocates memory and sets it via memset() and it gets to the ulimit setting without being stopped by the cgroup limit.
you want to set one or both of these -> memory.limit_in_bytes memory.memsw.limit_in_bytes max_usage_in_bytes just shows you the max that's been used in the cgroup so far. not sure why it's writeable.
The next problem of course will be having systemd-logind set the limit when it creates the cgroup. Any suggestions on that will be appreciated.
presumably https://www.freedesktop.org/software/systemd/man/systemd.resource-control.ht... but I haven't tried to do it yet. in centos6 I use pam_exec.so to run a cgroup modification script. eg. $ tail -1 /etc/pam.d/sshd session required pam_exec.so /opt/root/pam_user_cgroup where pam_user_group is a simple script that finds the right cgroup path and sets cpuset and mem limits. it uses env variables like PAM_USER and PPID to accomplish this. I expect this approach will still work with centos7, and perhaps could even be applied to login pam instead of ssh, but it may not be the most elegant solution ot the best integrated with systemd. I'd be interested in what you come up with. cheers, robin