summaryrefslogtreecommitdiffstats
path: root/pcp/Platform.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2023-05-02 09:02:22 +1000
committerNathan Scott <nathans@redhat.com>2023-05-08 13:06:07 +1000
commit0bdade1b6cb40c5bd374a93ac0489058a7421bb5 (patch)
tree0e0225f7dbf6867402c5ed3481a705d01941f42e /pcp/Platform.c
parente4ebe18b67c366d367231a1123b057c82018cf5b (diff)
Introduce Machine class for host-specific info (split from ProcessList)
First stage in sanitizing the process list structure so that htop can support other types of lists too (cgroups, filesystems, ...), in the not-too-distant future. This introduces struct Machine for system-wide information while keeping process-list information in ProcessList (now much less). Next step is to propogate this separation into each platform, to match these core changes.
Diffstat (limited to 'pcp/Platform.c')
-rw-r--r--pcp/Platform.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/pcp/Platform.c b/pcp/Platform.c
index 87de2c2f..181898aa 100644
--- a/pcp/Platform.c
+++ b/pcp/Platform.c
@@ -485,6 +485,7 @@ long long Platform_getBootTime(void) {
}
static double Platform_setOneCPUValues(Meter* this, pmAtomValue* values) {
+ Settings* settings = this->host->settings;
unsigned long long value = values[CPU_TOTAL_PERIOD].ull;
double total = (double) (value == 0 ? 1 : value);
@@ -493,7 +494,7 @@ static double Platform_setOneCPUValues(Meter* this, pmAtomValue* values) {
double* v = this->values;
v[CPU_METER_NICE] = values[CPU_NICE_PERIOD].ull / total * 100.0;
v[CPU_METER_NORMAL] = values[CPU_USER_PERIOD].ull / total * 100.0;
- if (this->pl->settings->detailedCPUTime) {
+ if (settings->detailedCPUTime) {
v[CPU_METER_KERNEL] = values[CPU_SYSTEM_PERIOD].ull / total * 100.0;
v[CPU_METER_IRQ] = values[CPU_IRQ_PERIOD].ull / total * 100.0;
v[CPU_METER_SOFTIRQ] = values[CPU_SOFTIRQ_PERIOD].ull / total * 100.0;
@@ -502,7 +503,7 @@ static double Platform_setOneCPUValues(Meter* this, pmAtomValue* values) {
v[CPU_METER_IOWAIT] = values[CPU_IOWAIT_PERIOD].ull / total * 100.0;
this->curItems = 8;
percent = v[CPU_METER_NICE] + v[CPU_METER_NORMAL] + v[CPU_METER_KERNEL] + v[CPU_METER_IRQ] + v[CPU_METER_SOFTIRQ];
- if (this->pl->settings->accountGuestInCPUMeter) {
+ if (settings->accountGuestInCPUMeter) {
percent += v[CPU_METER_STEAL] + v[CPU_METER_GUEST];
}
} else {
@@ -523,23 +524,24 @@ static double Platform_setOneCPUValues(Meter* this, pmAtomValue* values) {
}
double Platform_setCPUValues(Meter* this, int cpu) {
- const PCPProcessList* pl = (const PCPProcessList*) this->pl;
+ const PCPProcessList* pl = (const PCPProcessList*) this->host->pl;
if (cpu <= 0) /* use aggregate values */
return Platform_setOneCPUValues(this, pl->cpu);
return Platform_setOneCPUValues(this, pl->percpu[cpu - 1]);
}
void Platform_setMemoryValues(Meter* this) {
- const ProcessList* pl = this->pl;
+ const Machine* host = this->host;
+ const ProcessList* pl = host->pl;
const PCPProcessList* ppl = (const PCPProcessList*) pl;
- this->total = pl->totalMem;
- this->values[MEMORY_METER_USED] = pl->usedMem;
- this->values[MEMORY_METER_BUFFERS] = pl->buffersMem;
- this->values[MEMORY_METER_SHARED] = pl->sharedMem;
+ this->total = host->totalMem;
+ this->values[MEMORY_METER_USED] = host->usedMem;
+ this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
+ this->values[MEMORY_METER_SHARED] = host->sharedMem;
// this->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
- this->values[MEMORY_METER_CACHE] = pl->cachedMem;
- this->values[MEMORY_METER_AVAILABLE] = pl->availableMem;
+ this->values[MEMORY_METER_CACHE] = host->cachedMem;
+ this->values[MEMORY_METER_AVAILABLE] = host->availableMem;
if (ppl->zfs.enabled != 0) {
// ZFS does not shrink below the value of zfs_arc_min.
@@ -553,10 +555,10 @@ void Platform_setMemoryValues(Meter* this) {
}
void Platform_setSwapValues(Meter* this) {
- const ProcessList* pl = this->pl;
- this->total = pl->totalSwap;
- this->values[SWAP_METER_USED] = pl->usedSwap;
- this->values[SWAP_METER_CACHE] = pl->cachedSwap;
+ const Machine* host = this->host;
+ this->total = host->totalSwap;
+ this->values[SWAP_METER_USED] = host->usedSwap;
+ this->values[SWAP_METER_CACHE] = host->cachedSwap;
// this->values[SWAP_METER_FRONTSWAP] = "pages that are accounted to swap but stored elsewhere, like frontswap on linux"
}
@@ -593,13 +595,13 @@ void Platform_setZramValues(Meter* this) {
}
void Platform_setZfsArcValues(Meter* this) {
- const PCPProcessList* ppl = (const PCPProcessList*) this->pl;
+ const PCPProcessList* ppl = (const PCPProcessList*) this->host->pl;
ZfsArcMeter_readStats(this, &(ppl->zfs));
}
void Platform_setZfsCompressedArcValues(Meter* this) {
- const PCPProcessList* ppl = (const PCPProcessList*) this->pl;
+ const PCPProcessList* ppl = (const PCPProcessList*) this->host->pl;
ZfsCompressedArcMeter_readStats(this, &(ppl->zfs));
}

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