[Lxc-users] total RAM limit

Serge Hallyn serge.hallyn at canonical.com
Fri Feb 1 16:24:13 UTC 2013


Quoting Gary Ballantyne (gary.ballantyne at haulashore.com):
> On 01/02/13 02:33, lxc-users-request at lists.sourceforge.net wrote:
> >On 2013-01-31 07:41, Gary Ballantyne wrote:
> >>>*# echo '64M' > /sys/fs/cgroup/memory/lxc/memory.limit_in_bytes*
> >>># cat /sys/fs/cgroup/memory/lxc/memory.limit_in_bytes (return 67108864)
> >Dear Gary,
> >
> >what's the value of '/sys/fs/cgroup/memory/lxc/'? If it's not '1', all cgroup settings in "lxc" will not be used as a template for the container "lxc/foo".
> >
> >It might be much simpler to add lxc config entries like 'lxc.cgroup.memory.limit_in_bytes = 64M' to your container configuration.
> >
> >And to limit use of swap, to my knowledge you also have to limit 'memory.memsw...'. But i may be wrong, on my LXC environmet i don't use swap at all.
> >
> >
> >greetings
> >
> >Guido
> Thanks Guido
> 
> Did you mean the value of
> /sys/fs/cgroup/memory/lxc/cgroup.clone_children? That guy is '1'.
> 
> Modifying the container configuration certainly works --- but I'd
> like to limit the total RAM available to all containers, rather than
> limit each individual container. I tried setting
> lxc.cgroup.memory.limit_in_bytes to various values (-1, 1G) to see
> if the container would pick up
> /sys/fs/cgroup/memory/lxc/memory.limit_in_bytes --- but no luck.

Did you actually test with a memory hog program?  I just noticed there
appears to be a bug in that if I

	d=/sys/fs/cgroup/memory/a
	mkdir $d
	echo 1 > $d/memory.use_hierarchy
	echo 5000 > $d/memory.limit_in_bytes
	mkdir $d/b

then $d/b/memory.limit_in_bytes does not report the reduced limit.  However
whenI run a program which does char *c = malloc(10000) after doing
	echo $$ > $d/b/tasks

then I get killed by OOM.

-serge




More information about the lxc-users mailing list