diff options
author | Daniel Lange <DLange@git.local> | 2023-02-05 04:25:56 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2023-02-05 04:25:56 +0100 |
commit | f288666edc9180a2e81e6655951878124f321df6 (patch) | |
tree | da70bf44b2423f6f8e9a070c063fed79d190b489 /freebsd | |
parent | 937052b231259a47d881d539ad5748245ef55b99 (diff) | |
download | debian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.gz debian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.bz2 debian_htop-f288666edc9180a2e81e6655951878124f321df6.zip |
New upstream version 3.2.2upstream/3.2.2
Diffstat (limited to 'freebsd')
-rw-r--r-- | freebsd/FreeBSDProcessList.c | 12 | ||||
-rw-r--r-- | freebsd/Platform.c | 30 | ||||
-rw-r--r-- | freebsd/Platform.h | 18 |
3 files changed, 36 insertions, 24 deletions
diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index f58f338..2c7e20b 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -25,6 +25,7 @@ in the source distribution for its full text. #include <sys/time.h> #include <sys/types.h> #include <sys/user.h> +#include <sys/vmmeter.h> #include "CRT.h" #include "Compat.h" @@ -49,6 +50,7 @@ static int MIB_vm_stats_vm_v_active_count[4]; static int MIB_vm_stats_vm_v_cache_count[4]; static int MIB_vm_stats_vm_v_inactive_count[4]; static int MIB_vm_stats_vm_v_free_count[4]; +static int MIB_vm_vmtotal[2]; static int MIB_vfs_bufspace[2]; @@ -82,6 +84,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, H len = 4; sysctlnametomib("vm.stats.vm.v_cache_count", MIB_vm_stats_vm_v_cache_count, &len); len = 4; sysctlnametomib("vm.stats.vm.v_inactive_count", MIB_vm_stats_vm_v_inactive_count, &len); len = 4; sysctlnametomib("vm.stats.vm.v_free_count", MIB_vm_stats_vm_v_free_count, &len); + len = 2; sysctlnametomib("vm.vmtotal", MIB_vm_vmtotal, &len); len = 2; sysctlnametomib("vfs.bufspace", MIB_vfs_bufspace, &len); @@ -330,6 +333,7 @@ static inline void FreeBSDProcessList_scanMemoryInfo(ProcessList* pl) { u_int memActive, memWire, cachedMem; long buffersMem; size_t len; + struct vmtotal vmtotal; //disabled for now, as it is always smaller than phycal amount of memory... //...to avoid "where is my memory?" questions @@ -360,6 +364,10 @@ static inline void FreeBSDProcessList_scanMemoryInfo(ProcessList* pl) { cachedMem *= pageSizeKb; pl->cachedMem = cachedMem; + len = sizeof(vmtotal); + sysctl(MIB_vm_vmtotal, 2, &(vmtotal), &len, NULL, 0); + pl->sharedMem = vmtotal.t_vmshr * pageSizeKb; + if (fpl->zfs.enabled) { fpl->memWire -= fpl->zfs.size; pl->cachedMem += fpl->zfs.size; @@ -397,6 +405,7 @@ static void FreeBSDProcessList_updateExe(const struct kinfo_proc* kproc, Process } static void FreeBSDProcessList_updateCwd(const struct kinfo_proc* kproc, Process* proc) { +#ifdef KERN_PROC_CWD const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_CWD, kproc->ki_pid }; char buffer[2048]; size_t size = sizeof(buffer); @@ -414,6 +423,9 @@ static void FreeBSDProcessList_updateCwd(const struct kinfo_proc* kproc, Process } free_and_xStrdup(&proc->procCwd, buffer); +#else + proc->procCwd = NULL; +#endif } static void FreeBSDProcessList_updateProcessName(kvm_t* kd, const struct kinfo_proc* kproc, Process* proc) { diff --git a/freebsd/Platform.c b/freebsd/Platform.c index 1a731b7..646163a 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -148,7 +148,7 @@ void Platform_setBindings(Htop_Action* keys) { (void) keys; } -int Platform_getUptime() { +int Platform_getUptime(void) { struct timeval bootTime, currTime; const int mib[2] = { CTL_KERN, KERN_BOOTTIME }; size_t size = sizeof(bootTime); @@ -179,7 +179,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) { *fifteen = (double) loadAverage.ldavg[2] / loadAverage.fscale; } -int Platform_getMaxPid() { +int Platform_getMaxPid(void) { int maxPid; size_t size = sizeof(maxPid); int err = sysctlbyname("kern.pid_max", &maxPid, &size, NULL, 0); @@ -230,28 +230,28 @@ void Platform_setMemoryValues(Meter* this) { const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) pl; this->total = pl->totalMem; - this->values[0] = pl->usedMem; - this->values[1] = pl->buffersMem; - // this->values[2] = "shared memory, like tmpfs and shm" - this->values[3] = pl->cachedMem; - // this->values[4] = "available memory" + this->values[MEMORY_METER_USED] = pl->usedMem; + this->values[MEMORY_METER_BUFFERS] = pl->buffersMem; + this->values[MEMORY_METER_SHARED] = pl->sharedMem; + this->values[MEMORY_METER_CACHE] = pl->cachedMem; + // this->values[MEMORY_METER_AVAILABLE] = "available memory" if (fpl->zfs.enabled) { // ZFS does not shrink below the value of zfs_arc_min. unsigned long long int shrinkableSize = 0; if (fpl->zfs.size > fpl->zfs.min) shrinkableSize = fpl->zfs.size - fpl->zfs.min; - this->values[0] -= shrinkableSize; - this->values[3] += shrinkableSize; - // this->values[4] += shrinkableSize; + this->values[MEMORY_METER_USED] -= shrinkableSize; + this->values[MEMORY_METER_CACHE] += shrinkableSize; + // this->values[MEMORY_METER_AVAILABLE] += shrinkableSize; } } void Platform_setSwapValues(Meter* this) { const ProcessList* pl = this->pl; this->total = pl->totalSwap; - this->values[0] = pl->usedSwap; - this->values[1] = NAN; + this->values[SWAP_METER_USED] = pl->usedSwap; + this->values[SWAP_METER_CACHE] = NAN; } void Platform_setZfsArcValues(Meter* this) { @@ -287,12 +287,6 @@ char* Platform_getProcessEnv(pid_t pid) { return env; } -char* Platform_getInodeFilename(pid_t pid, ino_t inode) { - (void)pid; - (void)inode; - return NULL; -} - FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) { (void)pid; return NULL; diff --git a/freebsd/Platform.h b/freebsd/Platform.h index c0292d9..51269c0 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -59,8 +59,6 @@ void Platform_setZfsCompressedArcValues(Meter* this); char* Platform_getProcessEnv(pid_t pid); -char* Platform_getInodeFilename(pid_t pid, ino_t inode); - FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid); bool Platform_getDiskIO(DiskIOData* data); @@ -93,7 +91,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -103,12 +103,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif |