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
>
> 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?

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

Reply via email to