1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Aaron Sokoloski <asokoloski@gmail.com>
3 Date: Sat, 2 Dec 2017 12:43:06 -0600
4 Subject: [PATCH lxcfs] Fix inaccurate values in /proc/meminfo for containers
7 The values for Cached, Active, Inactive, Active(anon), Inactive(anon),
8 Active(file), Inactive(file), and Unevictable are derived/computed
9 from these values in the relevant meminfo.stat:
18 However, these value apply only to the cgroup of the lxc container
19 itself. If your container uses memory cgroups internally, and thus
20 the container cgroup has children, their memory is not counted.
22 In order to take the memory usage of child cgroups into account, we
23 need to look at the "total_" prefixed versions of these values.
25 Signed-off-by: Aaron Sokoloski <asokoloski@gmail.com>
27 bindings.c | 24 ++++++++++++------------
28 1 file changed, 12 insertions(+), 12 deletions(-)
30 diff --git a/bindings.c b/bindings.c
31 index d7c2d1d..fc62089 100644
34 @@ -2959,23 +2959,23 @@ static void parse_memstat(char *memstat, unsigned long *cached,
38 - if (startswith(memstat, "cache")) {
39 - sscanf(memstat + 5, "%lu", cached);
40 + if (startswith(memstat, "total_cache")) {
41 + sscanf(memstat + 11, "%lu", cached);
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);
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);
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);
69 eol = strchr(memstat, '\n');