A great new metric has been introduced in “/proc/meminfo” in the Linux 3.14 kernel — MemAvailable:
An estimate of how much memory is available for starting new applications, without swapping. Calculated from MemFree, SReclaimable, the size of the file LRU lists, and the low watermarks in each zone.
The estimate takes into account that the system needs some page cache to function well, and that not all reclaimable slab will be reclaimable, due to items being in use. The impact of those factors will vary from system to system.
I recommend that you read the kernel commit description for further details.
Since many people are still using Linux kernels before 3.14, I’ve backported this kernel patch to Perl. You can download the sources from GitHub: https://github.com/famzah/linux-memavailable-procfs
Many system administrators rely on the “free” tool to get a quick overview of the system’s memory usage.
Unfortunately, the latest “procps” package still doesn’t interpret the “MemAvailable” metric, and even if it did, we don’t have it in Linux kernels before 3.14. Actually, the developers of the “procps-ng” package (which is the Debian, Fedora and openSUSE fork of “procps“) have reacted and did the same thing as me. For kernels before 3.14 they emulate the metric in the same way, and for kernels after 3.14, they display the native metric from “/proc/meminfo”. This makes my Perl port more or less redundant.
This is the reason I wrote a quick replacement of the “free” tool in Perl. A few examples of it follow.
Typical memory usage overview, in MBytes:
famzah@vbox:~$ ./free.pl -m total used free anonymous kernel caches others Mem: 2488 1228 1259 608 24 580 15 -/+ caches 648 1840 Swap: 1565 0 1565
Typical memory usage overview, in percentage:
famzah@vbox:~$ ./free.pl -mp total used free anonymous kernel caches others Mem: 2488 49% 51% 24% 1% 23% 1% -/+ caches 26% 74% Swap: 1565 0% 100%
Extended memory usage overview, in MBytes:
famzah@vbox:~$ ./free.pl -me total used free anonymous kernel caches others Mem: 2488 1228 1260 608 24 580 14 -/+ caches 647 1840 Swap: 1565 0 1565 Extended memory usage info: Buffers 83 Cached 785 SwapCached 0 Shmem 308 AnonPages 300 Mapped 122 Unevict+Mlocked 5 Dirty+Writeback 0 NFS+Bounce 0
Extended memory usage overview, in percentage:
famzah@vbox:~$ ./free.pl -mep total used free anonymous kernel caches others Mem: 2488 49% 51% 24% 1% 23% 1% -/+ caches 26% 74% Swap: 1565 0% 100% Extended memory usage info: Buffers 3% Cached 32% SwapCached 0% Shmem 12% AnonPages 12% Mapped 5% Unevict+Mlocked 0% Dirty+Writeback 0% NFS+Bounce 0%
September 23, 2015 at 3:13 pm
i have a query regarding “Available Memory” i.e MemAvailable value in /proc/meminfo which you compute in a perl backport of the same in linux kernels > 3.14.
In Kernel C source as per the git link you mention when caclulating it they do finally for Slab reclaimable portion as follows :
+ * Part of the reclaimable swap consists of items that are in use,
+ * and cannot be freed. Cap this estimate at the low watermark.
+ available += global_page_state(NR_SLAB_RECLAIMABLE) –
+ min(global_page_state(NR_SLAB_RECLAIMABLE) / 2, wmark_low);
But you seem to be missing the “/2” in your perl backport module for same “Available Memory” calculation as below :
$available += $slab_reclaimable – min($slab_reclaimable, $wmark_low);
Am i missing anything here ?
thanks in adv
September 29, 2015 at 2:20 am
Kishore, this was right on the spot! Thank you. I’ve fixed this at GitHub.