diff mbox

[3/4] lxc: fuse: Fill in MemAvailable for /proc/meminfo

Message ID fb47010595f61646d599b40167cf5325d51d0466.1453401727.git.crobinso@redhat.com
State Accepted
Commit c7be484d1136834614089c9a74a3818594852f24
Headers show

Commit Message

Cole Robinson Jan. 21, 2016, 6:42 p.m. UTC
'free' on Fedora 23 will use MemAvailable to calculate its 'available'
field, but we are passing through the host's value. Set it to match
MemFree, which is what 'free' will do for older linux that don't have
MemAvailable

https://bugzilla.redhat.com/show_bug.cgi?id=1300781
---
 src/lxc/lxc_fuse.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.5.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index ffa6889..0a1c7dc 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -174,6 +174,14 @@  static int lxcProcReadMeminfo(char *hostpath, virDomainDefPtr def,
                     virDomainDefGetMemoryActual(def))) {
             virBufferAsprintf(new_meminfo, "MemFree:        %8llu kB\n",
                               (meminfo.memtotal - meminfo.memusage));
+        } else if (STREQ(line, "MemAvailable") &&
+                   (virMemoryLimitIsSet(def->mem.hard_limit) ||
+                    virDomainDefGetMemoryActual(def))) {
+            /* MemAvailable is actually MemFree + SRReclaimable +
+               some other bits, but MemFree is the closest approximation
+               we have */
+            virBufferAsprintf(new_meminfo, "MemAvailable:   %8llu kB\n",
+                              (meminfo.memtotal - meminfo.memusage));
         } else if (STREQ(line, "Buffers")) {
             virBufferAsprintf(new_meminfo, "Buffers:        %8d kB\n", 0);
         } else if (STREQ(line, "Cached")) {