Add ProcessList_isCPUonline

This commit is contained in:
Christian Göttsche 2021-06-12 22:04:37 +02:00 committed by Benny Baumann
parent 41af31be7f
commit 11d2206f40
18 changed files with 95 additions and 3 deletions

View File

@ -384,7 +384,9 @@ Panel* AffinityPanel_new(ProcessList* pl, const Affinity* affinity, int* width)
unsigned int curCpu = 0;
for (unsigned int i = 0; i < pl->existingCPUs; i++) {
/* TODO: skip offline CPUs */
if (!ProcessList_isCPUonline(this->pl, i))
continue;
char number[16];
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
unsigned cpu_width = 4 + strlen(number);
@ -428,8 +430,7 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
Affinity_add(affinity, i);
hwloc_bitmap_foreach_end();
#else
for (unsigned int i = 0; i < this->pl->existingCPUs; i++) {
/* TODO: skip offline CPUs */
for (int i = 0; i < Vector_size(this->cpuids); i++) {
const MaskItem* item = (const MaskItem*)Vector_get(this->cpuids, i);
if (item->value) {
Affinity_add(affinity, item->cpu);

View File

@ -87,9 +87,11 @@ typedef struct ProcessList_ {
unsigned int existingCPUs;
} ProcessList;
/* Implemented by platforms */
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
ProcessList* ProcessList_init(ProcessList* this, const ObjectClass* klass, UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* pidMatchList, uid_t userId);

View File

@ -236,3 +236,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
free(ps);
}
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;
}

View File

@ -34,4 +34,6 @@ void ProcessList_delete(ProcessList* this);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif

View File

@ -601,3 +601,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
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;
}

View File

@ -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

View File

@ -599,3 +599,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
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;
}

View File

@ -53,4 +53,6 @@ void ProcessList_delete(ProcessList* this);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif

View File

@ -2081,3 +2081,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
LinuxProcessList_recurseProcTree(this, rootFd, PROCDIR, NULL, period);
}
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
assert(id < super->existingCPUs);
const LinuxProcessList* this = (const LinuxProcessList*) super;
return this->cpuData[id + 1].online;
}

View File

@ -120,4 +120,6 @@ void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif

View File

@ -447,3 +447,16 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
OpenBSDProcessList_scanProcs(opl);
}
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
assert(id < super->existingCPUs);
const OpenBSDProcessList* opl = (const OpenBSDProcessList*) super;
for (unsigned int i = 0; i < super->activeCPUs; i++) {
if (opl->cpus[i].cpuIndex == id)
return true;
}
return false;
}

View File

@ -55,4 +55,6 @@ void ProcessList_delete(ProcessList* this);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif

View File

@ -675,3 +675,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
double period = (this->timestamp - sample) * 100;
PCPProcessList_updateProcesses(this, period, &timestamp);
}
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;
}

View File

@ -69,4 +69,6 @@ void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif

View File

@ -495,3 +495,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
super->kernelThreads = 1;
proc_walk(&SolarisProcessList_walkproc, super, PR_WALK_LWP);
}
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;
}

View File

@ -59,4 +59,6 @@ void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif

View File

@ -89,3 +89,11 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
if (!preExisting)
ProcessList_add(super, proc);
}
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
assert(id < super->existingCPUs);
(void) super; (void) id;
return true;
}

View File

@ -16,4 +16,6 @@ void ProcessList_delete(ProcessList* this);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);
#endif