PCP: use the correct metric for shared memory calculations

This commit is contained in:
Nathan Scott 2021-07-29 09:44:03 +10:00 committed by BenBE
parent 4f3ba680fb
commit 97d9b320ad
2 changed files with 5 additions and 7 deletions

View File

@ -431,7 +431,7 @@ static void PCPProcessList_updateMemoryInfo(ProcessList* super) {
unsigned long long int swapFreeMem = 0;
unsigned long long int sreclaimableMem = 0;
super->totalMem = super->usedMem = super->cachedMem = 0;
super->usedSwap = super->totalSwap = 0;
super->usedSwap = super->totalSwap = super->sharedMem = 0;
pmAtomValue value;
if (Metric_values(PCP_MEM_TOTAL, &value, 1, PM_TYPE_U64) != NULL)
@ -444,11 +444,9 @@ static void PCPProcessList_updateMemoryInfo(ProcessList* super) {
sreclaimableMem = value.ull;
if (Metric_values(PCP_MEM_SHARED, &value, 1, PM_TYPE_U64) != NULL)
super->sharedMem = value.ull;
if (Metric_values(PCP_MEM_CACHED, &value, 1, PM_TYPE_U64) != NULL) {
super->cachedMem = value.ull;
super->cachedMem += sreclaimableMem;
}
const memory_t usedDiff = freeMem + super->cachedMem + sreclaimableMem + super->buffersMem + super->sharedMem;
if (Metric_values(PCP_MEM_CACHED, &value, 1, PM_TYPE_U64) != NULL)
super->cachedMem = value.ull + sreclaimableMem - super->sharedMem;
const memory_t usedDiff = freeMem + super->cachedMem + sreclaimableMem + super->buffersMem;
super->usedMem = (super->totalMem >= usedDiff) ?
super->totalMem - usedDiff : super->totalMem - freeMem;
if (Metric_values(PCP_MEM_AVAILABLE, &value, 1, PM_TYPE_U64) != NULL)

View File

@ -157,7 +157,7 @@ static const char* Platform_metricNames[] = {
[PCP_MEM_AVAILABLE] = "mem.util.available",
[PCP_MEM_BUFFERS] = "mem.util.bufmem",
[PCP_MEM_CACHED] = "mem.util.cached",
[PCP_MEM_SHARED] = "mem.util.shared",
[PCP_MEM_SHARED] = "mem.util.shmem",
[PCP_MEM_SRECLAIM] = "mem.util.slabReclaimable",
[PCP_MEM_SWAPCACHED] = "mem.util.swapCached",
[PCP_MEM_SWAPTOTAL] = "mem.util.swapTotal",