There are two commands and two files.
]# free -V; vmstat -V
free from procps-ng 3.3.15
vmstat from procps-ng 3.3.15
Free's manpage explains about meminfo fields. Some of these fields are also calculated indirectly.
vmstat only adds some /proc/vmstat fields.
/proc/vmstat has a more systematic (and longer) structure. Here are four lines where that mysterious pagecache is mentioned
Now these strings are very weak compared to the enum list in mmzone.h, with comments:
NR_ANON_MAPPED, /* Mapped anonymous pages */
NR_FILE_MAPPED, /* pagecache pages mapped into pagetables. only modified from process context */
(In first place come the 4 lines ANON and FILES combined with ACTIVE and INACTIVE)
So your second one is not a command, but the contents of the proc file the commands rely on.
cached = global_node_page_state(NR_FILE_PAGES) -
total_swapcache_pages() - i.bufferram;
if (cached < 0)
cached = 0;
This illustrates there is no own "cached" counter, and it has to be sanity checked. It is basically all the "file pages", active or inactive, with some corrections.
i.buffers is added back in the 'buff/cache' field of
This part (/proc/meminfo contents) shows how the values are collected together.
i is a struct sysinfo. cached and available are calculated right before. The pages array is very like /proc/vmstat, also Mlocked with that zone page call.
show_val_kb(m, "MemTotal: ", i.totalram);
show_val_kb(m, "MemFree: ", i.freeram);
show_val_kb(m, "MemAvailable: ", available);
show_val_kb(m, "Buffers: ", i.bufferram);
show_val_kb(m, "Cached: ", cached);
show_val_kb(m, "SwapCached: ", total_swapcache_pages());
show_val_kb(m, "Active: ", pages[LRU_ACTIVE_ANON] +
show_val_kb(m, "Inactive: ", pages[LRU_INACTIVE_ANON] +
show_val_kb(m, "Active(anon): ", pages[LRU_ACTIVE_ANON]);
show_val_kb(m, "Inactive(anon): ", pages[LRU_INACTIVE_ANON]);
show_val_kb(m, "Active(file): ", pages[LRU_ACTIVE_FILE]);
show_val_kb(m, "Inactive(file): ", pages[LRU_INACTIVE_FILE]);
show_val_kb(m, "Unevictable: ", pages[LRU_UNEVICTABLE]);
show_val_kb(m, "Mlocked: ", global_zone_page_state(NR_MLOCK));
swap cache is what man free calls cache:
cache: Memory used by the page cache and slabs (Cached and SReclaimable in /proc/meminfo)
Because of (simplified, see above):
cached = NR_FILE_PAGES - total_swapcache_pages()
...there is a interesting relationship with SwapCached. If only the names were less confusing.
What swap cache is for files on disk, SwapCached is for ANON pages on a swap device. (I hope this makes sense/is not totally wrong)