Fix Busted Swap Accounting
Fix Busted Swap Accounting

When no limit is specified using lxc.cgroup.memory.memsw.limit_in_bytes,
overflow occurs while calculating Swap{Total,Free}. Commit a2de34b tried
to fix this, but introduced another bug, wherein if
memory.memsw.limit_in_bytes >= memory.limit_in_bytes, then Swap{Total,Free}
are not shown as expected.

When a container is spawned with the settings...

lxc.cgroup.memory.limit_in_bytes = 256M
lxc.cgroup.memory.memsw.limit_in_bytes = 512M

...I find that inside the container, we have:

[root@test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           256         24        231          6          0         20
-/+ buffers/cache:          3        252
Swap:         1023          0       1023

The total swap should have been 256MB, but it is being
shown as ~1GB (same as host). Basically, the memsw setting is being
ignored.

This patch attempts to fix this by assuming that the when no limit is
specified, the value is same that as of cgroup /

Signed-off-by: Nehal J Wani <1e5530bf40ec86c47cb9fcec00e13620c1950060@gmail.com>
Acked-by: Serge E. Hallyn <3df611b026e4639bee8aef7a4beb2e39fcebb313@ubuntu.com>

evgeni/pkg-lxcfs-debian,evgeni/pkg-lxcfs-debian,Xeno22/lxcfs,Xeno22/lxcfs