[pve-devel] [PATCH lxcfs] fix #1173: wrong /proc/meminfo content

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Oct 19 09:41:08 CEST 2016


---
Note: forwarded upstream

 .../patches/fix-Active-Inactive-proc-meminfo.patch | 30 +++++++++++++++
 .../fix-offsets-for-memory.stat-parsing.patch      | 45 ++++++++++++++++++++++
 debian/patches/series                              |  2 +
 3 files changed, 77 insertions(+)
 create mode 100644 debian/patches/fix-Active-Inactive-proc-meminfo.patch
 create mode 100644 debian/patches/fix-offsets-for-memory.stat-parsing.patch

diff --git a/debian/patches/fix-Active-Inactive-proc-meminfo.patch b/debian/patches/fix-Active-Inactive-proc-meminfo.patch
new file mode 100644
index 0000000..d36f133
--- /dev/null
+++ b/debian/patches/fix-Active-Inactive-proc-meminfo.patch
@@ -0,0 +1,30 @@
+From 3f4847aacd7cb56d7859f1562c81c06acf9d41d5 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler at proxmox.com>
+Date: Wed, 19 Oct 2016 09:16:36 +0200
+Subject: [PATCH] fix Active/Inactive /proc/meminfo
+
+---
+ bindings.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/bindings.c b/bindings.c
+index 2f78ab5..0d46fb8 100644
+--- a/bindings.c
++++ b/bindings.c
+@@ -3197,11 +3197,11 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
+ 		} else if (startswith(line, "SwapCached:")) {
+ 			snprintf(lbuf, 100, "SwapCached:     %8lu kB\n", 0UL);
+ 			printme = lbuf;
+-		} else if (startswith(line, "Active")) {
++		} else if (startswith(line, "Active:")) {
+ 			snprintf(lbuf, 100, "Active:         %8lu kB\n",
+ 					active_anon + active_file);
+ 			printme = lbuf;
+-		} else if (startswith(line, "Inactive")) {
++		} else if (startswith(line, "Inactive:")) {
+ 			snprintf(lbuf, 100, "Inactive:       %8lu kB\n",
+ 					inactive_anon + inactive_file);
+ 			printme = lbuf;
+-- 
+2.1.4
+
diff --git a/debian/patches/fix-offsets-for-memory.stat-parsing.patch b/debian/patches/fix-offsets-for-memory.stat-parsing.patch
new file mode 100644
index 0000000..ca937fa
--- /dev/null
+++ b/debian/patches/fix-offsets-for-memory.stat-parsing.patch
@@ -0,0 +1,45 @@
+From 145cc4a9922aeabeecce69225c9476aaffe147ad Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler at proxmox.com>
+Date: Wed, 19 Oct 2016 09:06:59 +0200
+Subject: [PATCH] fix offsets for memory.stat parsing
+
+---
+ bindings.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/bindings.c b/bindings.c
+index 2f78ab5..f433ea2 100644
+--- a/bindings.c
++++ b/bindings.c
+@@ -2958,22 +2958,22 @@ static void parse_memstat(char *memstat, unsigned long *cached,
+ 
+ 	while (*memstat) {
+ 		if (startswith(memstat, "cache")) {
+-			sscanf(memstat + 11, "%lu", cached);
++			sscanf(memstat + sizeof("cache"), "%lu", cached);
+ 			*cached /= 1024;
+ 		} else if (startswith(memstat, "active_anon")) {
+-			sscanf(memstat + 11, "%lu", active_anon);
++			sscanf(memstat + sizeof("active_anon"), "%lu", active_anon);
+ 			*active_anon /= 1024;
+ 		} else if (startswith(memstat, "inactive_anon")) {
+-			sscanf(memstat + 11, "%lu", inactive_anon);
++			sscanf(memstat + sizeof("inactive_anon"), "%lu", inactive_anon);
+ 			*inactive_anon /= 1024;
+ 		} else if (startswith(memstat, "active_file")) {
+-			sscanf(memstat + 11, "%lu", active_file);
++			sscanf(memstat + sizeof("active_file"), "%lu", active_file);
+ 			*active_file /= 1024;
+ 		} else if (startswith(memstat, "inactive_file")) {
+-			sscanf(memstat + 11, "%lu", inactive_file);
++			sscanf(memstat + sizeof("inactive_file"), "%lu", inactive_file);
+ 			*inactive_file /= 1024;
+ 		} else if (startswith(memstat, "unevictable")) {
+-			sscanf(memstat + 11, "%lu", unevictable);
++			sscanf(memstat + sizeof("unevictable"), "%lu", unevictable);
+ 			*unevictable /= 1024;
+ 		}
+ 		eol = strchr(memstat, '\n');
+-- 
+2.1.4
+
diff --git a/debian/patches/series b/debian/patches/series
index bf650b4..d226b69 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
 do-not-start-without-lxcfs.patch
+fix-offsets-for-memory.stat-parsing.patch
+fix-Active-Inactive-proc-meminfo.patch
-- 
2.1.4





More information about the pve-devel mailing list