Idle threads not so idle

I’ve been noticing that Haiku (hrev 49897) seems to use a lot of CPU even when idling. This is inside VirtualBox 5.0, but even so, I can see in the Haiku CPU usage monitor that kernel_group->idle thread {1-4} stay pretty busy. In the host environment (OS X) this equates to 3-5 times more CPU usage than other VB installs and up to 20% of one core-thread (I’ve got one of the MacBook Pros where Activity Monitor gets confused and thinks I have 8 cores). By comparison, using a streaming music server with OmniWeb (via Flash) on the host, CPU usage is only about 7.5% of a core-thread. Using Power saving reduces the usage by about 10%.

Is this normal?

Thank you,

The idle threads are “fake” threads for when the CPU is sleeping. There is one per CPU core. So this does not count as busy. Your problem is elsewhere…

Is there a way within Haiku to determine the percentage of time the CPU is active and in use? Bar graphs don’t really tell me anything.

After remembering “top” in the CLUI, I spent a bit of time running it. It consistently shows about 0.6% CPU usage for identifiable tasks and about 0.3%-0.4% listed as “unknown.” Since the CPU usage is therefore on the host side, in VirtualBox, is it possible that VB is seeing a lot of hardware interrupts that need to be handled? Is there a way to monitor or log hardware interrupts in Haiku?

You can enter the kernel debugger using alt+print screen+d, or maybe more easily in a VM, using the “kernel_debugger” command. Then, you can use “ints” from the kernel debuffer prompt to get some info about interrupts.

Not sure how to call the “kernel_debugger” command. Doesn’t seem to be found. Is this an option that needs to be enabled in the kernel?

Apple keyboards do not have the print screen/sysreq key, so as per, the host command-line command

VBoxManage controlvm Haiku keyboardputscancode 38 54 20

works - once. After that the kernel debugger seems to ignore the command. I’ve tried leaving the KDL using both exit and continue with the same result.

The CPU load by VirtualBox appears to increase with the number of windows and/or applications open in Haiku, even when VB is in a different workspace and Haiku has gone to the screensaver. Five open windows in Tracker and low latency takes about 26-28% of a core-core while five open windows in Tracker, fifteen open windows in PE and low latency take about 33% of a core-thread. This is a significant amount of power consumption, but admittedly not scientific.

After running for a few days, x86_ici_interrupt_FPv had over 31 million interrupts, whereas the others were ~8 million, ~5 million or a few thousand. After rebooting and running enough time to open five windows in Tracker, the same interrupt has handled 115,326 interrupts, while apic_timer_interrupt_FPv had 5589 and ata_adapter_inthand_FPv had 3225 (likely the ~8 million and ~5 million before, but I could not re-enter KDL to record this information precisely). The others are a few tens.

The code indicates that x86_ici_interrupt determines the current CPU in an SMP system and returns the handler for it. This interrupt is not present when VB creates a virtual host with a single CPU. Power consumption with a single CPU in low latency and PE running appears to be ~24% instead of the previous ~28-29% with a single window open. This suggests that there is a high number of interrupts for simply having multiple CPUs, which in turn take some power to process.

Why so many interrupts in comparison to the others, and is this a normal level of interrupts?