From 2d7069feb43bf20a7ad018aa3a11025e1f34c2ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 14 Apr 2021 18:26:38 +0200 Subject: [PATCH] Linux: handle Shmem being part of Cached See https://lore.kernel.org/patchwork/patch/648763/ Do not show twice by subtracting from Cached. Closes: #591 --- linux/LinuxProcessList.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index f5a35193..55a3b46f 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -1571,11 +1571,15 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) { /* * Compute memory partition like procps(free) * https://gitlab.com/procps-ng/procps/-/blob/master/proc/sysinfo.c + * + * Adjustments: + * - Shmem in part of Cached (see https://lore.kernel.org/patchwork/patch/648763/), + * do not show twice by subtracting from Cached and do not subtract twice from used. */ this->totalMem = totalMem; - this->cachedMem = cachedMem + sreclaimableMem; + this->cachedMem = cachedMem + sreclaimableMem - sharedMem; this->sharedMem = sharedMem; - const memory_t usedDiff = freeMem + cachedMem + sreclaimableMem + buffersMem + sharedMem; + const memory_t usedDiff = freeMem + cachedMem + sreclaimableMem + buffersMem; this->usedMem = (totalMem >= usedDiff) ? totalMem - usedDiff : totalMem - freeMem; this->buffersMem = buffersMem; this->availableMem = availableMem != 0 ? MINIMUM(availableMem, totalMem) : freeMem;