summaryrefslogtreecommitdiffstats
path: root/pcp
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2021-07-29 09:44:03 +1000
committerBenBE <BenBE@geshi.org>2021-07-29 10:14:51 +0200
commit97d9b320ad1ce3e8c505682a36ce663c59eeee1a (patch)
tree641776d19abbbbbe994134928e546ade3c962772 /pcp
parent4f3ba680fbf2af938d64b645aa5f6cc1d188cfc7 (diff)
PCP: use the correct metric for shared memory calculations
Diffstat (limited to 'pcp')
-rw-r--r--pcp/PCPProcessList.c10
-rw-r--r--pcp/Platform.c2
2 files changed, 5 insertions, 7 deletions
diff --git a/pcp/PCPProcessList.c b/pcp/PCPProcessList.c
index 5a02aba0..77f82095 100644
--- a/pcp/PCPProcessList.c
+++ b/pcp/PCPProcessList.c
@@ -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)
diff --git a/pcp/Platform.c b/pcp/Platform.c
index 082f4b5b..4ddf7e68 100644
--- a/pcp/Platform.c
+++ b/pcp/Platform.c
@@ -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",

© 2014-2024 Faster IT GmbH | imprint | privacy policy