summaryrefslogtreecommitdiffstats
path: root/collectors/proc.plugin
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2023-08-21 17:51:37 +0300
committerGitHub <noreply@github.com>2023-08-21 17:51:37 +0300
commit56479af525a113cf6230ab652629cdba829ed707 (patch)
tree29c2a8b8ac226e6795699156411e490042befad9 /collectors/proc.plugin
parent2fe29f9f838c6a56d97261d0f7f4259e476fdfc1 (diff)
fix proc meminfo cached calculation (#15859)
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r--collectors/proc.plugin/proc_meminfo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/collectors/proc.plugin/proc_meminfo.c b/collectors/proc.plugin/proc_meminfo.c
index cd1ba872c7..a357cc7824 100644
--- a/collectors/proc.plugin/proc_meminfo.c
+++ b/collectors/proc.plugin/proc_meminfo.c
@@ -230,7 +230,9 @@ int do_proc_meminfo(int update_every, usec_t dt) {
}
// http://calimeroteknik.free.fr/blag/?article20/really-used-memory-on-gnu-linux
- unsigned long long MemCached = Cached + SReclaimable + KReclaimable - Shmem;
+ // KReclaimable includes SReclaimable, it was added in kernel v4.20
+ unsigned long long reclaimable = KReclaimable > 0 ? KReclaimable : SReclaimable;
+ unsigned long long MemCached = Cached + reclaimable - Shmem;
unsigned long long MemUsed = MemTotal - MemFree - MemCached - Buffers;
// The Linux kernel doesn't report ZFS ARC usage as cache memory (the ARC is included in the total used system memory)
if (!inside_lxc_container) {