summaryrefslogtreecommitdiffstats
path: root/AffinityPanel.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-06-12 18:17:28 +0200
committerBenny Baumann <BenBE@geshi.org>2021-07-18 07:44:02 +0200
commit41af31be7ffbd34518b27aad56a4f54af6a8adf3 (patch)
tree6e86813a332e93f7ee22b873d7522fa766b4af97 /AffinityPanel.c
parentc9abd788b17ab28424961310b7e224498510780c (diff)
Rework CPU counting
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: #650 Related: #580
Diffstat (limited to 'AffinityPanel.c')
-rw-r--r--AffinityPanel.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/AffinityPanel.c b/AffinityPanel.c
index 25169994..56d8d89c 100644
--- a/AffinityPanel.c
+++ b/AffinityPanel.c
@@ -383,7 +383,8 @@ Panel* AffinityPanel_new(ProcessList* pl, const Affinity* affinity, int* width)
Panel_setHeader(super, "Use CPUs:");
unsigned int curCpu = 0;
- for (unsigned int i = 0; i < pl->cpuCount; i++) {
+ for (unsigned int i = 0; i < pl->existingCPUs; i++) {
+ /* TODO: skip offline CPUs */
char number[16];
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
unsigned cpu_width = 4 + strlen(number);
@@ -427,7 +428,8 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
Affinity_add(affinity, i);
hwloc_bitmap_foreach_end();
#else
- for (unsigned int i = 0; i < this->pl->cpuCount; i++) {
+ for (unsigned int i = 0; i < this->pl->existingCPUs; i++) {
+ /* TODO: skip offline CPUs */
const MaskItem* item = (const MaskItem*)Vector_get(this->cpuids, i);
if (item->value) {
Affinity_add(affinity, item->cpu);

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