Skip to content

Commit 53868d2

Browse files
committed
Fix 'virtualized' CPU bar color in non-detailed mode
Linux and PCP platform code used to write the 'virtualized' (steal+guest) CPU time into the CPU_METER_IRQ item when the "detailed CPU time" option is off, which would result in a wrong color painted for virtual CPU time in bar mode. Correct it by writing to the CPU_METER_STEAL item instead. Also update the "virtualized" CPU meter item in the help screen: (1) The color is now CPU_STEAL for consistency. (2) In monochrome mode, two dummy items are displayed before the "virtualized" word so that the bar meter symbol mapping is correct. Resolves: #1920 Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 5f62abd commit 53868d2

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

Action.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,11 @@ static Htop_Reaction actionHelp(State* st) {
743743
addbartext(CRT_colors[CPU_GUEST], "/", "guest");
744744
addbartext(CRT_colors[CPU_IOWAIT], "/", "io-wait");
745745
addbartext(CRT_colors[BAR_SHADOW], " ", "used%");
746+
} else if (CRT_colorScheme == COLORSCHEME_MONOCHROME) {
747+
addbartext(CRT_colors[CPU_STEAL], "/-/-/", "virtualized");
748+
addbartext(CRT_colors[BAR_SHADOW], " ", "used%");
746749
} else {
747-
addbartext(CRT_colors[CPU_GUEST], "/", "virtualized");
750+
addbartext(CRT_colors[CPU_STEAL], "/", "virtualized");
748751
addbartext(CRT_colors[BAR_SHADOW], " ", "used%");
749752
}
750753
addattrstr(CRT_colors[BAR_BORDER], "]");

linux/Platform.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,11 @@ double Platform_setCPUValues(Meter* this, unsigned int cpu) {
373373
v[CPU_METER_KERNEL] = cpuData->systemAllPeriod / total * 100.0;
374374
this->curItems = 3;
375375

376-
v[CPU_METER_IRQ] = (cpuData->stealPeriod + cpuData->guestPeriod) / total * 100.0;
376+
v[CPU_METER_IRQ] = 0.0; // Accounted in 'kernel'
377+
v[CPU_METER_SOFTIRQ] = 0.0; // Accounted in 'kernel'
378+
v[CPU_METER_STEAL] = (cpuData->stealPeriod + cpuData->guestPeriod) / total * 100.0;
377379
if (settings->accountGuestInCPUMeter) {
378-
this->curItems = 4;
380+
this->curItems = 6;
379381
}
380382
}
381383

pcp/Platform.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,12 @@ static double Platform_setOneCPUValues(Meter* this, const Settings* settings, pm
562562
v[CPU_METER_KERNEL] = values[CPU_SYSTEM_ALL_PERIOD].ull / total * 100.0;
563563
this->curItems = 3;
564564

565+
v[CPU_METER_IRQ] = 0.0;
566+
v[CPU_METER_SOFTIRQ] = 0.0;
565567
value = values[CPU_STEAL_PERIOD].ull + values[CPU_GUEST_PERIOD].ull;
566-
v[CPU_METER_IRQ] = value / total * 100.0;
568+
v[CPU_METER_STEAL] = value / total * 100.0;
567569
if (settings->accountGuestInCPUMeter) {
568-
this->curItems = 4;
570+
this->curItems = 6;
569571
}
570572
}
571573

0 commit comments

Comments
 (0)