From dfa40ad0ebdb40a859ea16a264e775ce766bb037 Mon Sep 17 00:00:00 2001 From: multi Date: Thu, 24 Sep 2020 19:13:25 +0100 Subject: [PATCH] Linux: consider the ZFS ARC to be cache. This commit is based on a patch originally by @edef1c. The ZFS ARC is a cache (it's in the name), which will be evicted by the kernel if memory pressure so requires. Hence, the ARC should not be counted towards a system's total used memory, and should instead be grouped with the other caches in the system. Signed-off-by: edef --- linux/Platform.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/linux/Platform.c b/linux/Platform.c index 0545fc46..4550097a 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -202,6 +202,8 @@ double Platform_setCPUValues(Meter* this, int cpu) { void Platform_setMemoryValues(Meter* this) { ProcessList* pl = (ProcessList*) this->pl; + LinuxProcessList* lpl = (LinuxProcessList*) this->pl; + long int usedMem = pl->usedMem; long int buffersMem = pl->buffersMem; long int cachedMem = pl->cachedMem; @@ -210,6 +212,11 @@ void Platform_setMemoryValues(Meter* this) { this->values[0] = usedMem; this->values[1] = buffersMem; this->values[2] = cachedMem; + + if (lpl->zfs.enabled != 0) { + this->values[0] -= lpl->zfs.size; + this->values[2] += lpl->zfs.size; + } } void Platform_setSwapValues(Meter* this) {