[lxc-devel] [lxcfs/master] meminfo: show host swap values when no limit or equal limits are set

brauner on Github lxc-bot at linuxcontainers.org
Tue Nov 3 21:28:00 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 379 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201103/b87626af/attachment.bin>
-------------- next part --------------
From 6da2a084789ed0122cacde5ee950cb9689daf7c4 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 3 Nov 2020 22:27:05 +0100
Subject: [PATCH] meminfo: show host swap values when no limit or equal limits
 are set

Closes: #434
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/proc_fuse.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 907f5c7..7bc1eb0 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -1243,7 +1243,17 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
 
 				sscanf(line + STRLITERALLEN("SwapTotal:"), "%" PRIu64, &hostswtotal);
 
-				if (hostswtotal < swtotal) {
+				/*
+				 * If swtotal is 0 it should mean that
+				 * memory.memsw.limit_in_bytes and
+				 * memory.limit_in_bytes are both unlimited or
+				 * both set to the same value. In both cases we
+				 * have no idea what the technical swap limit
+				 * is supposed to be (It's a shared limit
+				 * anyway.) so fallback to the host's values in
+				 * that case too.
+				 */
+				if ((hostswtotal < swtotal) || swtotal == 0) {
 					swtotal = hostswtotal;
 					host_swap = true;
 				}


More information about the lxc-devel mailing list