]> git.proxmox.com Git - lxcfs.git/blob - debian/patches/0001-Limit-memswlimit-by-TotalSwap.patch
bump version to 2.0.6-pve500 for stretch
[lxcfs.git] / debian / patches / 0001-Limit-memswlimit-by-TotalSwap.patch
1 From f4f2e7852fab28ec01b0634f6f2063a6e321e5e6 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Thu, 2 Feb 2017 09:36:46 +0100
4 Subject: [PATCH lxcfs] Limit memswlimit by TotalSwap
5
6 We do this for the memlimit when hitting MemTotal which
7 means if neither is limited we end up subtracting the
8 hosts's total memory from the 'unlimited' swap value in the
9 SwapTotal and SwapFree lines.
10
11 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
12 ---
13 bindings.c | 8 ++++++--
14 1 file changed, 6 insertions(+), 2 deletions(-)
15
16 diff --git a/bindings.c b/bindings.c
17 index 2d4c36a..e116ff6 100644
18 --- a/bindings.c
19 +++ b/bindings.c
20 @@ -3086,7 +3086,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
21 *memswlimit_str = NULL, *memswusage_str = NULL;
22 unsigned long memlimit = 0, memusage = 0, memswlimit = 0, memswusage = 0,
23 cached = 0, hosttotal = 0, active_anon = 0, inactive_anon = 0,
24 - active_file = 0, inactive_file = 0, unevictable = 0;
25 + active_file = 0, inactive_file = 0, unevictable = 0,
26 + hostswtotal = 0;
27 char *line = NULL;
28 size_t linelen = 0, total_len = 0, rv = 0;
29 char *cache = d->buf;
30 @@ -3148,7 +3149,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
31
32 memset(lbuf, 0, 100);
33 if (startswith(line, "MemTotal:")) {
34 - sscanf(line+14, "%lu", &hosttotal);
35 + sscanf(line+sizeof("MemTotal:")-1, "%lu", &hosttotal);
36 if (hosttotal < memlimit)
37 memlimit = hosttotal;
38 snprintf(lbuf, 100, "MemTotal: %8lu kB\n", memlimit);
39 @@ -3160,6 +3161,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
40 snprintf(lbuf, 100, "MemAvailable: %8lu kB\n", memlimit - memusage);
41 printme = lbuf;
42 } else if (startswith(line, "SwapTotal:") && memswlimit > 0) {
43 + sscanf(line+sizeof("SwapTotal:")-1, "%lu", &hostswtotal);
44 + if (hostswtotal < memswlimit - memlimit)
45 + memswlimit = hostswtotal + memlimit;
46 snprintf(lbuf, 100, "SwapTotal: %8lu kB\n", memswlimit - memlimit);
47 printme = lbuf;
48 } else if (startswith(line, "SwapFree:") && memswlimit > 0 && memswusage > 0) {
49 --
50 2.1.4
51