]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
memory plugin: Remove "slab" and "available" memory.
authorFlorian Forster <octo@collectd.org>
Thu, 4 Jan 2024 07:58:14 +0000 (08:58 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 15 Jan 2024 14:21:58 +0000 (15:21 +0100)
Under Linux, the plugin reported "slab" (kernel data structures cache) and
"available" (estimate of how much memory might be available without swapping).
These metrics group memory along different dimensions than other reported
memory, leading to double counting of some memory. The result was that the sum
of all memory metrics was not constant.

src/memory.c

index 51d63179cb39a27e8a4206f91c75071757736fe2..a7519176110706bd146fbaf966c41ef27a227960 100644 (file)
@@ -69,9 +69,6 @@ typedef enum {
   STATE_FREE,
   STATE_BUFFERS,
   STATE_CACHED,
-  STATE_SLAB_TOTAL,
-  STATE_SLAB_RECL,
-  STATE_SLAB_UNRECL,
   STATE_WIRED,
   STATE_ACTIVE,
   STATE_INACTIVE,
@@ -79,30 +76,15 @@ typedef enum {
   STATE_LOCKED,
   STATE_ARC,
   STATE_UNUSED,
-  STATE_AVAILABLE,
   STATE_USER_WIRE,
   STATE_LAUNDRY,
   STATE_MAX, /* #states */
 } memory_type_t;
 
 static char const *memory_type_names[STATE_MAX] = {
-    "used",
-    "free",
-    "buffers",
-    "cached",
-    "slab",
-    "slab_reclaimable",
-    "slab_unreclaimable",
-    "wired",
-    "active",
-    "inactive",
-    "kernel",
-    "locked",
-    "arc",
-    "unusable",
-    "available",
-    "user_wire",
-    "laundry",
+    "used",     "free",      "buffers", "cached", "wired",
+    "active",   "inactive",  "kernel",  "locked", "arc",
+    "unusable", "user_wire", "laundry",
 };
 
 /* vm_statistics_data_t */
@@ -463,14 +445,6 @@ static int memory_read_internal(gauge_t values[STATE_MAX]) {
     } else if (strcmp(fields[0], "Cached:") == 0) {
       values[STATE_CACHED] = v;
       mem_not_used += v;
-    } else if (strcmp(fields[0], "Slab:") == 0) {
-      values[STATE_SLAB_TOTAL] = v;
-    } else if (strcmp(fields[0], "SReclaimable:") == 0) {
-      values[STATE_SLAB_RECL] = v;
-    } else if (strcmp(fields[0], "SUnreclaim:") == 0) {
-      values[STATE_SLAB_UNRECL] = v;
-    } else if (strcmp(fields[0], "MemAvailable:") == 0) {
-      values[STATE_AVAILABLE] = v;
     }
   }
 
@@ -478,15 +452,6 @@ static int memory_read_internal(gauge_t values[STATE_MAX]) {
     WARNING("memory plugin: fclose failed: %s", STRERRNO);
   }
 
-  /* If SReclaimable (introduced in kernel 2.6.19) is available count it
-   * (but not SUnreclaim) towards the unused memory.
-   * If we do not have detailed slab info count the total as unused. */
-  if (!isnan(values[STATE_SLAB_RECL])) {
-    mem_not_used += values[STATE_SLAB_RECL];
-  } else if (!isnan(values[STATE_SLAB_TOTAL])) {
-    mem_not_used += values[STATE_SLAB_TOTAL];
-  }
-
   if (isnan(mem_total) || (mem_total == 0) || (mem_total < mem_not_used)) {
     return EINVAL;
   }
@@ -494,14 +459,6 @@ static int memory_read_internal(gauge_t values[STATE_MAX]) {
   /* "used" is not explicitly reported. It is calculated as everything that is
    * not "not used", e.g. cached, buffers, ... */
   values[STATE_USED] = mem_total - mem_not_used;
-
-  /* SReclaimable and SUnreclaim were introduced in kernel 2.6.19
-   * They sum up to the value of Slab, which is available on older & newer
-   * kernels. So SReclaimable/SUnreclaim are submitted if available, and Slab
-   * if not. */
-  if (!isnan(values[STATE_SLAB_RECL]) || !isnan(values[STATE_SLAB_UNRECL])) {
-    values[STATE_SLAB_TOTAL] = NAN;
-  }
   /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBKSTAT