]> git.proxmox.com Git - lxcfs.git/blame - debian/patches/0001-Fix-inaccurate-values-in-proc-meminfo-for-containers.patch
bump version to 2.0.8-2
[lxcfs.git] / debian / patches / 0001-Fix-inaccurate-values-in-proc-meminfo-for-containers.patch
CommitLineData
9b3df637
WB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Aaron Sokoloski <asokoloski@gmail.com>
3Date: Sat, 2 Dec 2017 12:43:06 -0600
4Subject: [PATCH lxcfs] Fix inaccurate values in /proc/meminfo for containers
5 with child cgroups
6
7The values for Cached, Active, Inactive, Active(anon), Inactive(anon),
8Active(file), Inactive(file), and Unevictable are derived/computed
9from these values in the relevant meminfo.stat:
10
11cache
12active_anon
13inactive_anon
14active_file
15inactive_file
16unevictable
17
18However, these value apply only to the cgroup of the lxc container
19itself. If your container uses memory cgroups internally, and thus
20the container cgroup has children, their memory is not counted.
21
22In order to take the memory usage of child cgroups into account, we
23need to look at the "total_" prefixed versions of these values.
24
25Signed-off-by: Aaron Sokoloski <asokoloski@gmail.com>
26---
27 bindings.c | 24 ++++++++++++------------
28 1 file changed, 12 insertions(+), 12 deletions(-)
29
30diff --git a/bindings.c b/bindings.c
31index d7c2d1d..fc62089 100644
32--- a/bindings.c
33+++ b/bindings.c
34@@ -2959,23 +2959,23 @@ static void parse_memstat(char *memstat, unsigned long *cached,
35 char *eol;
36
37 while (*memstat) {
38- if (startswith(memstat, "cache")) {
39- sscanf(memstat + 5, "%lu", cached);
40+ if (startswith(memstat, "total_cache")) {
41+ sscanf(memstat + 11, "%lu", cached);
42 *cached /= 1024;
43- } else if (startswith(memstat, "active_anon")) {
44- sscanf(memstat + 11, "%lu", active_anon);
45+ } else if (startswith(memstat, "total_active_anon")) {
46+ sscanf(memstat + 17, "%lu", active_anon);
47 *active_anon /= 1024;
48- } else if (startswith(memstat, "inactive_anon")) {
49- sscanf(memstat + 13, "%lu", inactive_anon);
50+ } else if (startswith(memstat, "total_inactive_anon")) {
51+ sscanf(memstat + 19, "%lu", inactive_anon);
52 *inactive_anon /= 1024;
53- } else if (startswith(memstat, "active_file")) {
54- sscanf(memstat + 11, "%lu", active_file);
55+ } else if (startswith(memstat, "total_active_file")) {
56+ sscanf(memstat + 17, "%lu", active_file);
57 *active_file /= 1024;
58- } else if (startswith(memstat, "inactive_file")) {
59- sscanf(memstat + 13, "%lu", inactive_file);
60+ } else if (startswith(memstat, "total_inactive_file")) {
61+ sscanf(memstat + 19, "%lu", inactive_file);
62 *inactive_file /= 1024;
63- } else if (startswith(memstat, "unevictable")) {
64- sscanf(memstat + 11, "%lu", unevictable);
65+ } else if (startswith(memstat, "total_unevictable")) {
66+ sscanf(memstat + 17, "%lu", unevictable);
67 *unevictable /= 1024;
68 }
69 eol = strchr(memstat, '\n');
70--
712.11.0
72