2 Replies Latest reply: Aug 1, 2012 3:40 PM by micheloe RSS

    OL6.3 with UEK2 and Linux Containers: memory controller limits not working

    micheloe
      Hi,

      I'm playing around with LXC (Linux Containers) on OL 6.3 with UEK2. So far I'm getting nice working results with containers and now I want to restrict CPU and memory. However, when trying the latter it fails when trying to limit the cgroup memory.limit_in_bytes and/or memory.memsw.limit_in_bytes in the cgroup memory controller. Cgroup cpuset is fine BTW. When I try to start a custom made container with lxc-start and memory limits enabled, it fails to write the memory.limit_in_bytes cgroup setting:

      -----
      # lxc-start -n zdtemp
      lxc-start: write /cgroup/temp/memory.limit_in_bytes : Invalid argument
      lxc-start: failed to setup the cgroups for 'temp'
      lxc-start: failed to setup the container
      lxc-start: invalid sequence number 1. expected 2
      lxc-start: failed to spawn 'temp'
      lxc-start: Device or resource busy - failed to remove cgroup '/cgroup/temp'
      -----

      In my container config, the memory limit is configured as follows:

      -----
      lxc.cgroup.memory.limit_in_bytes = 536870912
      lxc.cgroup.memory.memsw.limit_in_bytes = 805306368
      -----

      cgroup is mounted, and the entries for memory.limit_in_bytes and memory.memsw.limit_in_bytes are there when I start the container without these settings enabled. When I do so, I can manually set the memory limits through lxc-cgroup just fine:

      -----
      # lxc-cgroup -n temp memory.limit_in_bytes
      9223372036854775807
      # lxc-cgroup -n temp memory.limit_in_bytes 536870912
      # lxc-cgroup -n temp memory.limit_in_bytes
      536870912
      -----

      Also the lxc-checkconfig shows the cgroup memory controller is enabled. I've verified my configuration with people from #lxcontainers on freenode and the conclusion was that something vendor-specific must be wrong. So... any clues as to what might be the problem?

      Regards,
      micheloe
        • 1. Re: OL6.3 with UEK2 and Linux Containers: memory controller limits not working
          Catch-22
          I have to admit that I have absolutely no experience with LXC at all, but unless someone comes up with a better idea, I would check the following:

          - are there any invalid characters in the file, e.g. (cat -vet config.file)
          - is there a particular order of parameters or does one rely on another?
          - is there supposed to be a space between the = sign or not?
          - are the hardware resources available?
          • 2. Re: OL6.3 with UEK2 and Linux Containers: memory controller limits not working
            micheloe
            Hi Dude,

            Thanks for your response, it lead to the culprit of the problem. :-) I put a comment behind the memory settings, which is not supported. Something along the lines like this:

            -----
            # Define maximum memory/swap
            lxc.cgroup.memory.limit_in_bytes = 1G # means: Maximum 1G of memory
            lxc.cgroup.memory.memsw.limit_in_bytes = 2G # means: 1G of memory, 1G of swap
            -----

            Changing it to something like below made it work:

            -----
            # Define maximum memory/swap
            lxc.cgroup.memory.limit_in_bytes = 1G
            lxc.cgroup.memory.memsw.limit_in_bytes = 2G
            -----

            Unbelievable I didn't think of this earlier! Shows my good intentions of documenting everything bit me in my behind. :-)

            Regards,
            micheloe