diff options
author | Daniel Lange <DLange@git.local> | 2021-08-02 15:21:07 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2021-08-02 15:21:07 +0200 |
commit | ed82ce6456f0f904a0ab2b346b85d7cf46df109c (patch) | |
tree | 1b02b20548da6dbcdf53872c3c99a3c013588fd1 /dragonflybsd | |
parent | e341217fea844e1c45b7079146b9de7cb68e8c2a (diff) | |
parent | edf236f9fcf257c5266cead0c3bc45087d937e65 (diff) |
Merge branch 'cpu_count' of cgzones/htop
Diffstat (limited to 'dragonflybsd')
-rw-r--r-- | dragonflybsd/DragonFlyBSDProcessList.c | 23 | ||||
-rw-r--r-- | dragonflybsd/DragonFlyBSDProcessList.h | 2 | ||||
-rw-r--r-- | dragonflybsd/Platform.c | 2 |
3 files changed, 19 insertions, 8 deletions
diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 9bf6ffef..9b1bb41f 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -95,13 +95,15 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, H sysctl(MIB_kern_cp_times, 2, dfpl->cp_times_o, &len, NULL, 0); } - pl->cpuCount = MAXIMUM(cpus, 1); + pl->existingCPUs = MAXIMUM(cpus, 1); + // TODO: support offline CPUs and hot swapping + pl->activeCPUs = pl->existingCPUs; if (cpus == 1 ) { dfpl->cpus = xRealloc(dfpl->cpus, sizeof(CPUData)); } else { // on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well) - dfpl->cpus = xRealloc(dfpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData)); + dfpl->cpus = xRealloc(dfpl->cpus, (pl->existingCPUs + 1) * sizeof(CPUData)); } len = sizeof(kernelFScale); @@ -140,8 +142,8 @@ void ProcessList_delete(ProcessList* this) { static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) { const DragonFlyBSDProcessList* dfpl = (DragonFlyBSDProcessList*) pl; - unsigned int cpus = pl->cpuCount; // actual CPU count - unsigned int maxcpu = cpus; // max iteration (in case we have average + smp) + unsigned int cpus = pl->existingCPUs; // actual CPU count + unsigned int maxcpu = cpus; // max iteration (in case we have average + smp) int cp_times_offset; assert(cpus > 0); @@ -430,7 +432,6 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { int count = 0; - // TODO Kernel Threads seem to be skipped, need to figure out the correct flag const struct kinfo_proc* kprocs = kvm_getprocs(dfpl->kd, KERN_PROC_ALL | (!hideUserlandThreads ? KERN_PROC_FLAG_LWP : 0), 0, &count); for (int i = 0; i < count; i++) { @@ -442,8 +443,6 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { Process* proc = ProcessList_getProcess(super, kproc->kp_ktaddr ? (pid_t)kproc->kp_ktaddr : kproc->kp_pid, &preExisting, DragonFlyBSDProcess_new); DragonFlyBSDProcess* dfp = (DragonFlyBSDProcess*) proc; - proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc)) || (hideUserlandThreads && Process_isUserlandThread(proc))); - if (!preExisting) { dfp->jid = kproc->kp_jailid; if (kproc->kp_ktaddr && kproc->kp_flags & P_SYSTEM) { @@ -596,6 +595,16 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { if (proc->state == 'R') super->runningTasks++; + proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc)) || (hideUserlandThreads && Process_isUserlandThread(proc))); proc->updated = true; } } + +bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) { + assert(id < super->existingCPUs); + + // TODO: support offline CPUs and hot swapping + (void) super; (void) id; + + return true; +} diff --git a/dragonflybsd/DragonFlyBSDProcessList.h b/dragonflybsd/DragonFlyBSDProcessList.h index b9c9b5c8..626d2b24 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.h +++ b/dragonflybsd/DragonFlyBSDProcessList.h @@ -59,4 +59,6 @@ void ProcessList_delete(ProcessList* this); void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate); +bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id); + #endif diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index 39983f08..30fb0031 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -159,7 +159,7 @@ int Platform_getMaxPid() { double Platform_setCPUValues(Meter* this, unsigned int cpu) { const DragonFlyBSDProcessList* fpl = (const DragonFlyBSDProcessList*) this->pl; - unsigned int cpus = this->pl->cpuCount; + unsigned int cpus = this->pl->activeCPUs; const CPUData* cpuData; if (cpus == 1) { |