From 602b9a02ce2a3ed443b0b79fca457826da44d654 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Sat, 24 Oct 2015 14:29:25 +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: 05d751c4f076a2f0118b914c5e51cfbb4762ad8e 6cb75efef85f735b72e6c96f197f358f511f8ed9 --- free.1 | 2 +- proc/meminfo.c | 5 ++++- 2 files changed, 5 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/meminfo.c b/proc/meminfo.c index 44dbc88b..d2677e76 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -49,6 +49,7 @@ struct meminfo_data { unsigned long total; unsigned long used; unsigned long slab; + unsigned long slab_reclaimable; unsigned long swap_free; unsigned long swap_total; unsigned long swap_used; @@ -185,6 +186,8 @@ PROCPS_EXPORT int procps_meminfo_read ( case 'S': if (0 == strcmp(head, "Slab:")) valptr = &(info->data.slab); + if (0 == strcmp(head, "SReclaimable:")) + valptr = &(info->data.slab_reclaimable); else if (0 == strcmp(head, "SwapFree:")) valptr = &(info->data.swap_free); else if (0 == strcmp(head, "SwapTotal:")) @@ -212,7 +215,7 @@ PROCPS_EXPORT int procps_meminfo_read ( if (0 == info->data.available) { info->data.available = info->data.free; } - info->data.cached += info->data.slab; + info->data.cached += info->data.slab_reclaimable; info->data.swap_used = info->data.swap_total - info->data.swap_free; /* if 'available' is greater than 'total' or our calculation of mem_used -- 2.40.0