mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-10 03:04:36 +03:00
Merge branch 'cpu_count' of cgzones/htop
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user