]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Do not account reclaimable slab as used
authorWeiping Zhang <zhangweiping@didiglobal.com>
Mon, 17 May 2021 07:59:50 +0000 (15:59 +0800)
committerMatthias Runge <mrunge@matthias-runge.de>
Tue, 30 Nov 2021 17:00:37 +0000 (18:00 +0100)
ChangeLog: memory plugin: do not account reclaimable slab as used.

Align this counter with free(1).
https://gitlab.com/procps-ng/procps/-/blob/v3.3.17/proc/sysinfo.c#L789

Signed-off-by: Weiping Zhang <zhangweiping@didiglobal.com>
src/memory.c

index bc9a283bccd8327ec947662a90e10cdf123c2600..1adbdf80c26e8b76efc1e6f89275dde5e6cfbb21 100644 (file)
@@ -379,8 +379,12 @@ static int memory_read_internal(value_list_t *vl) {
   if (mem_total < (mem_free + mem_buffered + mem_cached + mem_slab_total))
     return -1;
 
-  mem_used =
-      mem_total - (mem_free + mem_buffered + mem_cached + mem_slab_total);
+  if (detailed_slab_info)
+    mem_used = mem_total -
+               (mem_free + mem_buffered + mem_cached + mem_slab_reclaimable);
+  else
+    mem_used =
+        mem_total - (mem_free + mem_buffered + mem_cached + mem_slab_total);
 
   /* SReclaimable and SUnreclaim were introduced in kernel 2.6.19
    * They sum up to the value of Slab, which is available on older & newer