Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap accounting looks busted #60

Closed
stgraber opened this issue Dec 14, 2015 · 3 comments
Closed

Swap accounting looks busted #60

stgraber opened this issue Dec 14, 2015 · 3 comments

Comments

@stgraber
Copy link
Member

root@blah:~# free -m
             total       used       free     shared    buffers     cached
Mem:         11912         58      11853         31          0         49
-/+ buffers/cache:          9      11903
Swap:   8796093010295          0 8796093010295
root@blah:~# 

Host value is 6GB of swap, container has no swap limit.

@hallyn
Copy link
Member

hallyn commented Dec 17, 2015 via email

@nehaljwani
Copy link
Contributor

Not sure, if I am having the same problem, but:

[root@test ~]# head /sys/fs/cgroup/memory/lxc/test/memory.memsw.*
==> /sys/fs/cgroup/memory/lxc/test/memory.memsw.failcnt <==
0

==> /sys/fs/cgroup/memory/lxc/test/memory.memsw.limit_in_bytes <==
268435456

==> /sys/fs/cgroup/memory/lxc/test/memory.memsw.max_usage_in_bytes <==
15876096

==> /sys/fs/cgroup/memory/lxc/test/memory.memsw.usage_in_bytes <==
15785984
[root@test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           256         15        240         33          0         10
-/+ buffers/cache:          4        251 
Swap:        24199        104      24095 


Host has 24199MB of swap, and:

ibm1:~/wani/lxcfs [539]# lxc-info -c lxc.cgroup.memory.limit_in_bytes -n test
lxc.cgroup.memory.limit_in_bytes = 256M

ibm1:~/wani/lxcfs [540]# lxc-info -c lxc.cgroup.memory.memsw.limit_in_bytes -n test
lxc.cgroup.memory.memsw.limit_in_bytes = 256M

If I revert the patch a2de34b, then the problem goes away for me.

nehaljwani added a commit to nehaljwani/lxcfs that referenced this issue Dec 18, 2015
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.

This patch assumes that if memory.memsw.limit_in_bytes is not set, then
/sys/fs/cgroup/memory/lxc/${CT_NAME}/memory.memsw.limit_in_bytes will have
the default value = LONG_MAX based on:
https://github.com/torvalds/linux/blob/v4.3/mm/memcontrol.c#L4037
https://github.com/torvalds/linux/blob/v4.3/mm/memcontrol.c#L2893
https://github.com/torvalds/linux/blob/v4.3/include/linux/page_counter.h#L21

Fixes lxc#60

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
nehaljwani added a commit to nehaljwani/lxcfs that referenced this issue Jan 8, 2016
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.

This patch assumes that if memory.memsw.limit_in_bytes is not set, then
/sys/fs/cgroup/memory/lxc/${CT_NAME}/memory.memsw.limit_in_bytes will have
the default value = LONG_MAX based on:
https://github.com/torvalds/linux/blob/v4.3/mm/memcontrol.c#L4037
https://github.com/torvalds/linux/blob/v4.3/mm/memcontrol.c#L2893
https://github.com/torvalds/linux/blob/v4.3/include/linux/page_counter.h#L21

Fixes lxc#60

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
@hallyn
Copy link
Member

hallyn commented Jan 12, 2016

@stgraber

I will assume this is fixed by the commit i referenced earlier.

@hallyn hallyn closed this as completed Jan 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants