summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-06-12 22:04:37 +0200
committerBenny Baumann <BenBE@geshi.org>2021-07-18 07:47:09 +0200
commit11d2206f40dd1680923ccae6e421a494c2af0992 (patch)
tree76513a64006184ee1bfc59ce9fa4aab1b0a2fc43
parent41af31be7ffbd34518b27aad56a4f54af6a8adf3 (diff)
Add ProcessList_isCPUonline
-rw-r--r--AffinityPanel.c7
-rw-r--r--ProcessList.h2
-rw-r--r--darwin/DarwinProcessList.c9
-rw-r--r--darwin/DarwinProcessList.h2
-rw-r--r--dragonflybsd/DragonFlyBSDProcessList.c9
-rw-r--r--dragonflybsd/DragonFlyBSDProcessList.h2
-rw-r--r--freebsd/FreeBSDProcessList.c9
-rw-r--r--freebsd/FreeBSDProcessList.h2
-rw-r--r--linux/LinuxProcessList.c7
-rw-r--r--linux/LinuxProcessList.h2
-rw-r--r--openbsd/OpenBSDProcessList.c13
-rw-r--r--openbsd/OpenBSDProcessList.h2
-rw-r--r--pcp/PCPProcessList.c9
-rw-r--r--pcp/PCPProcessList.h2
-rw-r--r--solaris/SolarisProcessList.c9
-rw-r--r--solaris/SolarisProcessList.h2
-rw-r--r--unsupported/UnsupportedProcessList.c8
-rw-r--r--unsupported/UnsupportedProcessList.h2
18 files changed, 95 insertions, 3 deletions
diff --git a/AffinityPanel.c b/AffinityPanel.c
index 56d8d89c..dbce5ca0 100644
--- a/AffinityPanel.c
+++ b/AffinityPanel.c
@@ -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);
diff --git a/ProcessList.h b/ProcessList.h
index 2b9a5070..93958cbb 100644
--- a/ProcessList.h
+++ b/ProcessList.h
@@ -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);
diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c
index e58c3496..8d14efe1 100644
--- a/darwin/DarwinProcessList.c
+++ b/darwin/DarwinProcessList.c
@@ -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;
+}
diff --git a/darwin/DarwinProcessList.h b/darwin/DarwinProcessList.h
index bd39ab0e..24259d3e 100644
--- a/darwin/DarwinProcessList.h
+++ b/darwin/DarwinProcessList.h
@@ -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
diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c
index 823bde59..2d3e08ba 100644
--- a/dragonflybsd/DragonFlyBSDProcessList.c
+++ b/dragonflybsd/DragonFlyBSDProcessList.c
@@ -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;
+}
diff --git a/dragonflybsd/DragonFlyBSDProcessList.h b/dragonflybsd/DragonFlyBSDProcessList.h
index 775be5c7..4cbc533e 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/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c
index 8c3f17db..407f38aa 100644
--- a/freebsd/FreeBSDProcessList.c
+++ b/freebsd/FreeBSDProcessList.c
@@ -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;
+}
diff --git a/freebsd/FreeBSDProcessList.h b/freebsd/FreeBSDProcessList.h
index ac6bcd0a..7efcda92 100644
--- a/freebsd/FreeBSDProcessList.h
+++ b/freebsd/FreeBSDProcessList.h
@@ -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
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 9fd07051..e5d38e5a 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -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;
+}
diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h
index 8cf81da8..2f296eca 100644
--- a/linux/LinuxProcessList.h
+++ b/linux/LinuxProcessList.h
@@ -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
diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c
index 09eb383c..4f8d7b9a 100644
--- a/openbsd/OpenBSDProcessList.c
+++ b/openbsd/OpenBSDProcessList.c
@@ -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;
+}
diff --git a/openbsd/OpenBSDProcessList.h b/openbsd/OpenBSDProcessList.h
index 5734d3ab..7e96b429 100644
--- a/openbsd/OpenBSDProcessList.h
+++ b/openbsd/OpenBSDProcessList.h
@@ -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
diff --git a/pcp/PCPProcessList.c b/pcp/PCPProcessList.c
index a27bd474..be91ca47 100644
--- a/pcp/PCPProcessList.c
+++ b/pcp/PCPProcessList.c
@@ -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;
+}
diff --git a/pcp/PCPProcessList.h b/pcp/PCPProcessList.h
index f1784904..7f0f6fe4 100644
--- a/pcp/PCPProcessList.h
+++ b/pcp/PCPProcessList.h
@@ -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
diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c
index 47d5182c..74f316b7 100644
--- a/solaris/SolarisProcessList.c
+++ b/solaris/SolarisProcessList.c
@@ -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;
+}
diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h
index e97d5cff..000d6ef1 100644
--- a/solaris/SolarisProcessList.h
+++ b/solaris/SolarisProcessList.h
@@ -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
diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c
index 8b6507bb..16c01558 100644
--- a/unsupported/UnsupportedProcessList.c
+++ b/unsupported/UnsupportedProcessList.c
@@ -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;
+}
diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h
index 10432758..764a1924 100644
--- a/unsupported/UnsupportedProcessList.h
+++ b/unsupported/UnsupportedProcessList.h
@@ -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

© 2014-2024 Faster IT GmbH | imprint | privacy policy