[lxc-devel] [lxcfs/master] 2016 03 07/cached

hallyn on Github lxc-bot at linuxcontainers.org
Mon Mar 7 23:55:02 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160307/f57512cc/attachment.bin>
-------------- next part --------------
From 6d2f69962f1dfa38290735e21d73e141a690cd95 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Mon, 7 Mar 2016 15:42:18 -0800
Subject: [PATCH 1/2] always use container root cgroup, not init pid's

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 bindings.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bindings.c b/bindings.c
index 25a5782..930494f 100644
--- a/bindings.c
+++ b/bindings.c
@@ -2897,6 +2897,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
 	cg = get_pid_cgroup(initpid, "memory");
 	if (!cg)
 		return read_file("/proc/meminfo", buf, size, d);
+	prune_init_slice(cg);
 
 	memlimit = get_min_memlimit(cg);
 	if (!cgfs_get_value("memory", cg, "memory.usage_in_bytes", &memusage_str))
@@ -3079,6 +3080,7 @@ static int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
 	cg = get_pid_cgroup(initpid, "cpuset");
 	if (!cg)
 		return read_file("proc/cpuinfo", buf, size, d);
+	prune_init_slice(cg);
 
 	cpuset = get_cpuset(cg);
 	if (!cpuset)
@@ -3182,6 +3184,7 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
 	cg = get_pid_cgroup(initpid, "cpuset");
 	if (!cg)
 		return read_file("/proc/stat", buf, size, d);
+	prune_init_slice(cg);
 
 	cpuset = get_cpuset(cg);
 	if (!cpuset)
@@ -3326,6 +3329,7 @@ static unsigned long get_reaper_busy(pid_t task)
 	cgroup = get_pid_cgroup(initpid, "cpuacct");
 	if (!cgroup)
 		goto out;
+	prune_init_slice(cgroup);
 	if (!cgfs_get_value("cpuacct", cgroup, "cpuacct.usage", &usage_str))
 		goto out;
 	usage = strtoul(usage_str, NULL, 10);
@@ -3445,6 +3449,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
 	cg = get_pid_cgroup(initpid, "blkio");
 	if (!cg)
 		return read_file("/proc/diskstats", buf, size, d);
+	prune_init_slice(cg);
 
 	if (!cgfs_get_value("blkio", cg, "blkio.io_serviced", &io_serviced_str))
 		goto err;
@@ -3568,6 +3573,7 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
 	cg = get_pid_cgroup(initpid, "memory");
 	if (!cg)
 		return read_file("/proc/swaps", buf, size, d);
+	prune_init_slice(cg);
 
 	if (!cgfs_get_value("memory", cg, "memory.limit_in_bytes", &memlimit_str))
 		goto err;

From da35d72a8f26be02bbd297d13e588fd694b86898 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Mon, 7 Mar 2016 15:50:50 -0800
Subject: [PATCH 2/2] meminfo_read: return 0 for Slab

Slab: is supposed to be the "in-kernel data structures cache".  I don't
know of a good way to calculate this from memory cgroup info.  If/when
we find it we can update it.  This value is used by free -m meaning
that if we don't shrink it, we can end up with negative values for
used memory.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 bindings.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bindings.c b/bindings.c
index 930494f..a16722c 100644
--- a/bindings.c
+++ b/bindings.c
@@ -2962,6 +2962,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
 			snprintf(lbuf, 100, "SwapFree:       %8lu kB\n", 
 				(memswlimit - memlimit) - (memswusage - memusage));
 			printme = lbuf;
+		} else if (startswith(line, "Slab:")) {
+			snprintf(lbuf, 100, "Slab:        %8lu kB\n", 0UL);
+			printme = lbuf;
 		} else if (startswith(line, "Buffers:")) {
 			snprintf(lbuf, 100, "Buffers:        %8lu kB\n", 0UL);
 			printme = lbuf;


More information about the lxc-devel mailing list