]> git.proxmox.com Git - mirror_lxcfs.git/blobdiff - bindings.c
Change MemAvailable figure in /proc/meminfo to include cache memory -- Fixes #175...
[mirror_lxcfs.git] / bindings.c
index bde433cb50836da6bf581c56b565bfe0913e5ca6..9657160fe485cf70a2248b3f9b8345dc818f76cc 100644 (file)
@@ -2961,23 +2961,23 @@ static void parse_memstat(char *memstat, unsigned long *cached,
        char *eol;
 
        while (*memstat) {
-               if (startswith(memstat, "cache")) {
-                       sscanf(memstat + 5, "%lu", cached);
+               if (startswith(memstat, "total_cache")) {
+                       sscanf(memstat + 11, "%lu", cached);
                        *cached /= 1024;
-               } else if (startswith(memstat, "active_anon")) {
-                       sscanf(memstat + 11, "%lu", active_anon);
+               } else if (startswith(memstat, "total_active_anon")) {
+                       sscanf(memstat + 17, "%lu", active_anon);
                        *active_anon /= 1024;
-               } else if (startswith(memstat, "inactive_anon")) {
-                       sscanf(memstat + 13, "%lu", inactive_anon);
+               } else if (startswith(memstat, "total_inactive_anon")) {
+                       sscanf(memstat + 19, "%lu", inactive_anon);
                        *inactive_anon /= 1024;
-               } else if (startswith(memstat, "active_file")) {
-                       sscanf(memstat + 11, "%lu", active_file);
+               } else if (startswith(memstat, "total_active_file")) {
+                       sscanf(memstat + 17, "%lu", active_file);
                        *active_file /= 1024;
-               } else if (startswith(memstat, "inactive_file")) {
-                       sscanf(memstat + 13, "%lu", inactive_file);
+               } else if (startswith(memstat, "total_inactive_file")) {
+                       sscanf(memstat + 19, "%lu", inactive_file);
                        *inactive_file /= 1024;
-               } else if (startswith(memstat, "unevictable")) {
-                       sscanf(memstat + 11, "%lu", unevictable);
+               } else if (startswith(memstat, "total_unevictable")) {
+                       sscanf(memstat + 17, "%lu", unevictable);
                        *unevictable /= 1024;
                }
                eol = strchr(memstat, '\n');
@@ -3167,7 +3167,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
                        snprintf(lbuf, 100, "MemFree:        %8lu kB\n", memlimit - memusage);
                        printme = lbuf;
                } else if (startswith(line, "MemAvailable:")) {
-                       snprintf(lbuf, 100, "MemAvailable:   %8lu kB\n", memlimit - memusage);
+                       snprintf(lbuf, 100, "MemAvailable:   %8lu kB\n", memlimit - memusage + cached);
                        printme = lbuf;
                } else if (startswith(line, "SwapTotal:") && memswlimit > 0) {
                        sscanf(line+sizeof("SwapTotal:")-1, "%lu", &hostswtotal);