[Lxc-users] lxc.cgroup.memory.limit_in_bytes has no effect
Memory limitation does not work for me: root@vms2:/lxc# uname -a Linux vms2 2.6.32-31-server #61-Ubuntu SMP Fri Apr 8 19:44:42 UTC 2011 x86_64 GNU/Linux root@vms2:/lxc# grep CONFIG_CGROUP_MEM_RES_CTLR /boot/config-2.6.32-31-server CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y root@vms2:/lxc# grep limit_in_bytes /lxc/flupp.cfg lxc.cgroup.memory.limit_in_bytes = 536870912 root@vms2:/lxc# lxc-version lxc version: 0.7.4.1 root@vms2:/lxc# lxc-start -d -n flupp -f /lxc/flupp.cfg root@vms2:/lxc# lxc-console -n flupp Type Ctrl+a q to exit the console root@flupp:~# ls -l /tmp/1GB.tmp -rw-r--r-- 1 root root 1073741824 2011-05-17 06:06 /tmp/1GB.tmp root@flupp:~# clp Command Line Perl with readline support, @ARGV and Specials. Type ? for help. (perl):: undef $/; open F,'/tmp/1GB.tmp' or die; $_=F; print length 1073741824 Why can a container process allocate more than 1 GB of memory if there is 512 MB limit? -- Ullrich Horlacher Server- und Arbeitsplatzsysteme Rechenzentrum E-Mail: horlac...@rus.uni-stuttgart.de Universitaet Stuttgart Tel:++49-711-685-65868 Allmandring 30 Fax:++49-711-682357 70550 Stuttgart (Germany) WWW:http://www.rus.uni-stuttgart.de/ -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
Re: [Lxc-users] lxc.cgroup.memory.limit_in_bytes has no effect
On 05/17/2011 08:34 AM, Ulli Horlacher wrote: Memory limitation does not work for me: root@vms2:/lxc# uname -a Linux vms2 2.6.32-31-server #61-Ubuntu SMP Fri Apr 8 19:44:42 UTC 2011 x86_64 GNU/Linux root@vms2:/lxc# grep CONFIG_CGROUP_MEM_RES_CTLR /boot/config-2.6.32-31-server CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y root@vms2:/lxc# grep limit_in_bytes /lxc/flupp.cfg lxc.cgroup.memory.limit_in_bytes = 536870912 root@vms2:/lxc# lxc-version lxc version: 0.7.4.1 root@vms2:/lxc# lxc-start -d -n flupp -f /lxc/flupp.cfg root@vms2:/lxc# lxc-console -n flupp TypeCtrl+a q to exit the console root@flupp:~# ls -l /tmp/1GB.tmp -rw-r--r-- 1 root root 1073741824 2011-05-17 06:06 /tmp/1GB.tmp root@flupp:~# clp Command Line Perl with readline support, @ARGV and Specials. Type ? for help. (perl):: undef $/; open F,'/tmp/1GB.tmp' or die; $_=F; print length 1073741824 Why can a container process allocate more than 1 GB of memory if there is 512 MB limit? I don't know exactly what does your perl program but I suggest you try with a simple C program: #include stdio.h #include sys/mman.h #include sys/poll.h int main(int argc, char *argv[]) { char *addr; addr = mmap(NULL, 512 * 1024 * 1024, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_POPULATE | MAP_ANONYMOUS, -1, 0); if (addr == MAP_FAILED) { perror(mmap); return -1; } poll(0, 0, -1); return 0; } When a process reaches the memory limit size then the container will begin to swap. This is not really what we want as it can impact the performances of the other container with continuous disk io. So the solution would be to set prevent the container to swap or play with the swapiness (not tried myself). In order to disable the swap, you have to set the memory.memsw.limit_in_bytes = memory.limit_in_bytes. -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
Re: [Lxc-users] lxc.cgroup.memory.limit_in_bytes has no effect
On Tue, May 17, 2011 at 09:10, Daniel Lezcano daniel.lezc...@free.fr wrote: On 05/17/2011 08:34 AM, Ulli Horlacher wrote: root@flupp:~# clp Command Line Perl with readline support, @ARGV and Specials. Type ? for help. (perl):: undef $/; open F,'/tmp/1GB.tmp' or die; $_=F; print length 1073741824 I don't know exactly what does your perl program It reads the whole file into a variable and then prints the length of that variable, which shows that the file has actually been read into memory. When a process reaches the memory limit size then the container will begin to swap. Yes, that's what I saw in a quick test. -- David Serrano -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users
Re: [Lxc-users] lxc.cgroup.memory.limit_in_bytes has no effect
On Tue 2011-05-17 (09:10), Daniel Lezcano wrote: Why can a container process allocate more than 1 GB of memory if there is 512 MB limit? When a process reaches the memory limit size then the container will begin to swap. This is not really what we want as Oh... no! In order to disable the swap, you have to set the memory.memsw.limit_in_bytes = memory.limit_in_bytes. Thanks! This does the trick! -- Ullrich Horlacher Server- und Arbeitsplatzsysteme Rechenzentrum E-Mail: horlac...@rus.uni-stuttgart.de Universitaet Stuttgart Tel:++49-711-685-65868 Allmandring 30 Fax:++49-711-682357 70550 Stuttgart (Germany) WWW:http://www.rus.uni-stuttgart.de/ -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay ___ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users