]> git.proxmox.com Git - mirror_lxcfs.git/commit
Change MemAvailable figure in /proc/meminfo to include cache memory -- Fixes #175...
authorAaron Sokoloski <asokoloski@gmail.com>
Mon, 4 Dec 2017 18:30:37 +0000 (12:30 -0600)
committerAaron Sokoloski <asokoloski@gmail.com>
Mon, 4 Dec 2017 19:41:23 +0000 (13:41 -0600)
commitad19b86d22ef75e1dac0ae9cc564089102ec043a
tree592daec4cb15edb09c78b16e0f27be6e67d11db3
parent4accebfb81919ea3d9566ee647cffc18b5bc03e6
Change MemAvailable figure in /proc/meminfo to include cache memory -- Fixes #175 I think.

MemAvailable represents roughly how much more memory we can use before
we start swapping.  Page cache memory can be reclaimed if it's needed
for something else, so it should count as available memory.  This
change should also fix the "available" column of the "free" command,
as well as the "avail Mem" value in "top", both of which come from
MemAvailable.

Note that this isn't perfectly accurate.  On a physical machine, the
value for MemAvailable is the result of a calculation that takes into
account that when memory gets low (but before it's completely
exhausted), kswapd wakes up and starts paging things out.  See:

https://github.com/torvalds/linux/blob/a0908a1b7d68706ee52ed4a039756e70c8e956e9/mm/page_alloc.c#L4553
(si_mem_available function)

I tried to think of a way to be more exact, but this calculation
includes figures that we don't have available for a given cgroup
hierarchy, such as reclaimable slab memory and the low watermark for
zones.  So it's not really feasible to reproduce it exactly.

Anyway, since the kernel calculation itself is just an estimation, it
doesn't seem too bad that we're a little bit off.  Adding in the
amount of memory used for page cache seems much better than what we
were doing before (just copying the free memory figure), because that
can be wrong by gigabytes.

For a more detailed understanding of how MemAvailable comes about one
should look at 34e431b0ae398fc54ea69ff85ec700722c9da773 in the Linux
kernel tree.

Signed-off-by: Aaron Sokoloski <asokoloski@gmail.com>
bindings.c