Use MemAvailable for memory calculations, if available
Brought to you by:
meskes,
paulcrawford
The current math seems to be incorrect in certain cases, e.g if a tmpfs is using memory,
this is not reflected in the current algorithm.
MemAvailble was introduced in kernel 3.14 and seems to be more correct in this aspect [1]
This patch is using MemAvailable if available and falls back to the old calculation if not.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0a
The supplied patch seemed to to actually read 'FREEAVAILMEM' anywhere! That has been fixed and the rest of the logic applied.