The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxcfs/pull/220
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === it make the value of (memswlimit - memlimit) to be swaptotal, it is wrong, because swapsize in cgroup/container can up to [0,memswlimit], sometimes if the memsize(unless swap) of all tasks in cgroup/container is very small, the swaptoal can to be memswlimit so make the swaptotal to be min(host swtoal,memswlimit) Signed-off-by: yuwang.yuwang <[email protected]>
From 4127e51bdc9dd46e8fa59be6a51c8a6e3333e313 Mon Sep 17 00:00:00 2001 From: "yuwang.yuwang" <[email protected]> Date: Fri, 20 Oct 2017 14:28:03 +0800 Subject: [PATCH] Fix wrong calc of swaptoal and swapfree it make the value of (memswlimit - memlimit) to be swaptotal, it is wrong, because swapsize in cgroup/container can up to [0,memswlimit], sometimes if the memsize(unless swap) of all tasks in cgroup/container is very small, the swaptoal can to be memswlimit so make the swaptotal to be min(host swtoal,memswlimit) Signed-off-by: yuwang.yuwang <[email protected]> --- bindings.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings.c b/bindings.c index d7c2d1d..fe521a3 100644 --- a/bindings.c +++ b/bindings.c @@ -3169,12 +3169,12 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset, printme = lbuf; } else if (startswith(line, "SwapTotal:") && memswlimit > 0) { sscanf(line+sizeof("SwapTotal:")-1, "%lu", &hostswtotal); - if (hostswtotal < memswlimit - memlimit) - memswlimit = hostswtotal + memlimit; - snprintf(lbuf, 100, "SwapTotal: %8lu kB\n", memswlimit - memlimit); + if (hostswtotal < memswlimit) + memswlimit = hostswtotal; + snprintf(lbuf, 100, "SwapTotal: %8lu kB\n", memswlimit); printme = lbuf; } else if (startswith(line, "SwapFree:") && memswlimit > 0 && memswusage > 0) { - unsigned long swaptotal = memswlimit - memlimit, + unsigned long swaptotal = memswlimit, swapusage = memswusage - memusage, swapfree = swapusage < swaptotal ? swaptotal - swapusage : 0; snprintf(lbuf, 100, "SwapFree: %8lu kB\n", swapfree);
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
