From 05d751c4f076a2f0118b914c5e51cfbb4762ad8e Mon Sep 17 00:00:00 2001 From: Craig Small Date: Sat, 24 Oct 2015 14:15:07 +1100 Subject: [PATCH] free: use SReclaimable in cached The previous commit added all of slab into the cache value. The thing was is cached in this context is something you can get back and reclaim if under memory pressure. The problem was slab parameter includes both reclaimable and unreclaimable values which doesn't make sense in this context. This commit make cached only use the reclaimable component. References: http://www.freelists.org/post/procps/OmegaPhilxxxxxxxxxxxxx-Bug799716-free-considers-cached-to-include-SUnreclaim https://github.com/brndnmtthws/conky/issues/130 https://bugs.debian.org/799716 Commits: 6cb75efef85f735b72e6c96f197f358f511f8ed9 --- free.1 | 2 +- proc/sysinfo.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/free.1 b/free.1 index 1cd01ef2..15f2b768 100644 --- a/free.1 +++ b/free.1 @@ -32,7 +32,7 @@ kernels 2.6.32, displayed as zero if not available) Memory used by kernel buffers (Buffers in /proc/meminfo) .TP \fBcache\fR -Memory used by the page cache and slabs (Cached and Slab in /proc/meminfo) +Memory used by the page cache and slabs (Cached and SReclaimable in /proc/meminfo) .TP \fBbuff/cache\fR Sum of \fBbuffers\fR and \fBcache\fR diff --git a/proc/sysinfo.c b/proc/sysinfo.c index b0af54f0..0619f20e 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -704,7 +704,7 @@ nextline: if(kb_inactive==~0UL){ kb_inactive = kb_inact_dirty + kb_inact_clean + kb_inact_laundry; } - kb_main_cached = kb_page_cache + kb_slab; + kb_main_cached = kb_page_cache + kb_slab_reclaimable; kb_swap_used = kb_swap_total - kb_swap_free; /* if kb_main_available is greater than kb_main_total or our calculation of