]> git.proxmox.com Git - lxcfs.git/blob - 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
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
5 with child cgroups
6
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:
10
11 cache
12 active_anon
13 inactive_anon
14 active_file
15 inactive_file
16 unevictable
17
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.
21
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.
24
25 Signed-off-by: Aaron Sokoloski <asokoloski@gmail.com>
26 ---
27 bindings.c | 24 ++++++++++++------------
28 1 file changed, 12 insertions(+), 12 deletions(-)
29
30 diff --git a/bindings.c b/bindings.c
31 index 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 --
71 2.11.0
72