Skip to content

Commit

Permalink
Add ProcessList_isCPUonline
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Jun 12, 2021
1 parent f26c27f commit 5408fd7
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 3 deletions.
7 changes: 4 additions & 3 deletions AffinityPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions ProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ typedef struct ProcessList_ {
unsigned int existingCPUs;
} ProcessList;

/* Implemented by platforms */
ProcessList* ProcessList_new(UsersTable* usersTable, 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* pidMatchList, uid_t userId);
Expand Down
9 changes: 9 additions & 0 deletions darwin/DarwinProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,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;
}
2 changes: 2 additions & 0 deletions darwin/DarwinProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions dragonflybsd/DragonFlyBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions dragonflybsd/DragonFlyBSDProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions freebsd/FreeBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions freebsd/FreeBSDProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions linux/LinuxProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,3 +2075,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;
}
2 changes: 2 additions & 0 deletions linux/LinuxProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions openbsd/OpenBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,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;
}
2 changes: 2 additions & 0 deletions openbsd/OpenBSDProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions pcp/PCPProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,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;
}
2 changes: 2 additions & 0 deletions pcp/PCPProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions solaris/SolarisProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,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;
}
2 changes: 2 additions & 0 deletions solaris/SolarisProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ void ProcessList_delete(ProcessList* pl);

void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);

bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id);

#endif
8 changes: 8 additions & 0 deletions unsupported/UnsupportedProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,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;
}
2 changes: 2 additions & 0 deletions unsupported/UnsupportedProcessList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5408fd7

Please sign in to comment.