Skip to content

Commit 78d5fc4

Browse files
committed
Use CPU_METER_STEAL for 'virtualized' CPU time 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. Write the 'virtualized' CPU time to CPU_METER_STEAL instead, which is more appropriate for the job. 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. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 0472535 commit 78d5fc4

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
@@ -803,8 +803,11 @@ static Htop_Reaction actionHelp(State* st) {
803803
addbartext(CRT_colors[CPU_GUEST], "/", "guest");
804804
addbartext(CRT_colors[CPU_IOWAIT], "/", "io-wait");
805805
addbartext(CRT_colors[BAR_SHADOW], " ", "used%");
806+
} else if (CRT_colorScheme == COLORSCHEME_MONOCHROME) {
807+
addbartext(CRT_colors[CPU_STEAL], "/-/-/", "virtualized");
808+
addbartext(CRT_colors[BAR_SHADOW], " ", "used%");
806809
} else {
807-
addbartext(CRT_colors[CPU_GUEST], "/", "virtualized");
810+
addbartext(CRT_colors[CPU_STEAL], "/", "virtualized");
808811
addbartext(CRT_colors[BAR_SHADOW], " ", "used%");
809812
}
810813
addattrstr(CRT_colors[BAR_BORDER], "]");

linux/Platform.c

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

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

pcp/Platform.c

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

579+
v[CPU_METER_IRQ] = 0.0;
580+
v[CPU_METER_SOFTIRQ] = 0.0;
579581
value = values[CPU_STEAL_PERIOD].ull + values[CPU_GUEST_PERIOD].ull;
580-
v[CPU_METER_IRQ] = value / total * 100.0;
582+
v[CPU_METER_STEAL] = value / total * 100.0;
581583
if (settings->accountGuestInCPUMeter) {
582-
this->curItems = 4;
584+
this->curItems = 6;
583585
}
584586
}
585587

0 commit comments

Comments
 (0)