canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.33k stars 927 forks source link

Swap Limit problem #4564

Closed hurelhuyag closed 6 years ago

hurelhuyag commented 6 years ago

I use to raw.lxc to limit memory and swap usage in previous version. But version 3.0.0 has different behaviour.

I use below configuration for limiting container memory usage.

raw.lxc: |-
    lxc.cgroup.memory.limit_in_bytes=7516192768
    lxc.cgroup.memory.memsw.limit_in_bytes=10737418240

If I set this config on pre 3.0 lxd container. free reports 3GB swap

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           7.0G        764M        6.2G        7.2G        4.1M        6.2G
Swap:          3.0G          0B        3.0G

But if I set this config on version 3.0. It reports 10GB swap available.

free -h
              total        used        free      shared  buff/cache   available
Mem:           7.0G         29M        7.0G        1.9M        236K        7.0G
Swap:           10G          0B         10G

Steps to reproduce

  1. install lxd configure with dir storage backend
  2. lxc profile edit default
  3. add above configuration
  4. lxc launch images:ubuntu/bionic c1
  5. lxc exec c1 bash
  6. free -h
stgraber commented 6 years ago

@brauner can you take a look?

brauner commented 6 years ago

On Wed, May 16, 2018 at 03:45:04AM -0700, hurelhuyag wrote:

I use to raw.lxc to limit memory and swap usage in previous version. But version 3.0.0 has different behaviour.

  • Distribution: ubuntu
  • Distribution version: bionic-x86_64
  • lxd info
    • Kernel version: 4.15.0-20-generic
    • LXC version: none
    • LXD version: 3.0.0-0ubuntu4
    • Storage backend in use: dir

I use below configuration for limiting container memory usage.

raw.lxc: |-
    lxc.cgroup.memory.limit_in_bytes=7516192768
    lxc.cgroup.memory.memsw.limit_in_bytes=10737418240

If I set this config on pre 3.0 lxd container. free reports 3GB swap

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           7.0G        764M        6.2G        7.2G        4.1M        6.2G
Swap:          3.0G          0B        3.0G

But if I set this config on version 3.0. It reports 10GB swap available.

free -h
              total        used        free      shared  buff/cache   available
Mem:           7.0G         29M        7.0G        1.9M        236K        7.0G
Swap:           10G          0B         10G

Steps to reproduce

  1. install lxd configure with dir storage backend
  2. lxc profile edit default
  3. add above configuration
  4. lxc launch images:ubuntu/bionic c1
  5. lxc exec c1 bash
  6. free -h

This sounds like changes related to lxcfs. The code in LXC and LXD hasn't really changed afaict. Did you upgrade LXCFS too if so can you only downgrade LXCFS and check if you observe the same behavior?

Christian

hurelhuyag commented 6 years ago

This behavior experienced in fresh installed ubuntu bionic server. I didn't tried to downgrade or upgrade. I see. It's related to lxcfs. Do I need to post this issue in lxcfs issue tracker?

here is dpkg result.

dpkg -l lx*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                            Version              Architecture         Description
+++-===============================-====================-====================-====================================================================
un  lxc-common                      <none>               <none>               (no description available)
un  lxc-templates                   <none>               <none>               (no description available)
un  lxc-utils                       <none>               <none>               (no description available)
un  lxc1                            <none>               <none>               (no description available)
ii  lxcfs                           3.0.0-0ubuntu1       amd64                FUSE based filesystem for LXC
ii  lxd                             3.0.0-0ubuntu4       amd64                Container hypervisor based on LXC - daemon
ii  lxd-client                      3.0.0-0ubuntu4       amd64                Container hypervisor based on LXC - client
un  lxd-tools                       <none>               <none>               (no description available)
brauner commented 6 years ago

@hurelhuyag, just to clarify this for me did you verify that it is related to LXCFS or are you just re-iterating? :)

stgraber commented 6 years ago

Closing as this is a lxcfs issue, there were a number of changes to lxcfs to try to fix inaccurate cache reporting which may have introduced some wrong logic around memsw handling...

Could you file a bug at https://github.com/lxc/lxcfs/issues, probably worth including: