diff options
author | Nathan Scott <nathans@redhat.com> | 2023-05-02 09:02:22 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2023-05-08 13:06:07 +1000 |
commit | 0bdade1b6cb40c5bd374a93ac0489058a7421bb5 (patch) | |
tree | 0e0225f7dbf6867402c5ed3481a705d01941f42e /freebsd/Platform.c | |
parent | e4ebe18b67c366d367231a1123b057c82018cf5b (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 'freebsd/Platform.c')
-rw-r--r-- | freebsd/Platform.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/freebsd/Platform.c b/freebsd/Platform.c index cab80929..3ba2778e 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -193,8 +193,9 @@ int Platform_getMaxPid(void) { } double Platform_setCPUValues(Meter* this, unsigned int cpu) { - const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->pl; - unsigned int cpus = this->pl->activeCPUs; + const Machine* host = this->host; + const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) host->pl; + unsigned int cpus = host->activeCPUs; const CPUData* cpuData; if (cpus == 1) { @@ -209,7 +210,7 @@ double Platform_setCPUValues(Meter* this, unsigned int cpu) { v[CPU_METER_NICE] = cpuData->nicePercent; v[CPU_METER_NORMAL] = cpuData->userPercent; - if (this->pl->settings->detailedCPUTime) { + if (host->settings->detailedCPUTime) { v[CPU_METER_KERNEL] = cpuData->systemPercent; v[CPU_METER_IRQ] = cpuData->irqPercent; this->curItems = 4; @@ -229,15 +230,16 @@ double Platform_setCPUValues(Meter* this, unsigned int cpu) { } void Platform_setMemoryValues(Meter* this) { - const ProcessList* pl = this->pl; + const Machine* host = this->host; + const ProcessList* pl = host->pl; const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) 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_CACHE] = host->cachedMem; // this->values[MEMORY_METER_AVAILABLE] = "available memory" if (fpl->zfs.enabled) { @@ -252,21 +254,22 @@ 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; + const Machine* host = this->host; + + this->total = host->totalSwap; + this->values[SWAP_METER_USED] = host->usedSwap; // this->values[SWAP_METER_CACHE] = "pages that are both in swap and RAM, like SwapCached on linux" // this->values[SWAP_METER_FRONTSWAP] = "pages that are accounted to swap but stored elsewhere, like frontswap on linux" } void Platform_setZfsArcValues(Meter* this) { - const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->pl; + const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->host->pl; ZfsArcMeter_readStats(this, &(fpl->zfs)); } void Platform_setZfsCompressedArcValues(Meter* this) { - const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->pl; + const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->host->pl; ZfsCompressedArcMeter_readStats(this, &(fpl->zfs)); } |