I recently received an email from Dr. David P. Reed with an interesting observation; high wakeup rates for an idle kvm windows xp guest machine measured using the powertop utility. His email went on to say the following:
Can you explain why powertop shows 3700 wakeups per second caused by Linux-KVM running a WinXP guest?
The powertop output with qemu-kvm running looks like (on latest Fedora Core 9):
Top causes for wakeups: 74.9% (3724.0) qemu-kvm : sys_timer_settime (posix_timer_fn) 20.5% (1020.6): Rescheduling interrupts 1.3% ( 64.4) : function call interrupts 1.2% ( 61.0) : ohci_hcd:usb4, ohci_hcd:usb6, ahci, pata_jmi 0.7% ( 35.8) : ehci_hcd:usb1, pata_jmicron, eth0 0.4% ( 19.0) : pata_atiixp
This is running on an AMD Phenom 9500 with 8 GB of memory, 64-bit kernel. I'm now using virtio network drivers, but that made no difference in interrupt rate. Note that with KVM not running the wakeup rate is minimal (< 100/sec).
Powertop is basically a linux utility that helps you find what software is using the most power. According to wikipedia link here , it was released by intel in 2007 under the GPL v2 license so it can be freely distributed. The wiki describes powertop as follows.
PowerTOP analyzes the programs, device drivers, and kernel options running on a computer based on the Linux operating system, and estimates the power consumption resulting from their use. This information may be used to pinpoint software that results in excessive power use. Many open source and free software programs, such as Mozilla Firefox [1], have been patched to reduce their power consumption since the release of PowerTOP. This is particularly useful for laptop computer users who wish to prolong battery life, and datacenter operators, for whom electrical and cooling costs are a major expenditure. Latest Version: 1.10 (June, 2008)
Powertop is probably already distributed as a package on your favourite linux distro. If not, you can download and install it by downloading from the following url. http://www.lesswatts.org/projects/powertop/download.php
To run powertop, linux kernel 2.6.21 or newer with dynticks enabled is required. The following options should be enabled in the kernel.
CONFIG_NO_HZ CONFIG_HIGH_RES_TIMERS CONFIG_HPET_TIMER CONFIG_CPU_FREQ_GOV_ONDEMAND CONFIG_USB_SUSPEND CONFIG_SND_AC97_POWER_SAVE CONFIG_TIMER_STATS
To verify that these are enabled in the kernel, grep for each of the listed modules in your kernel configuration. For example, to check for CONFIG_NO_HZ option in your kernel, run the following replacing the config with your kernel configuration file.
# grep CONFIG_NO_HZ /boot/config-2.6.25.4-30.fc9.x86_64 CONFIG_NO_HZ=y
Powertop is used by simply typing powertop within a terminal window on your linux host. Powertop will then begin collecting statistics for a default of 5 seconds as shown below:
[root@localhost ~]# powertop PowerTOP 1.9 (C) 2007 Intel Corporation Collecting data for 5 seconds
After collecting data, powertop will then output information that looks similar to the below; it shows powertop output for an idle windows xp guest machine:

Below shows powertop output for an idle Fedora 9 guest machine:

At the top of the powertop output are C states. C states represent the operating mode of the CPU, higher states reflecting lower power usage. C0 is special in that it is the only state in which the cpu is actually executing instructions (thereby consuming the most power). All the other C states represent an idle cpu not executing instructions.
For maximum power savings, your cpu should ideally be running in C states C3 and C4 most of the time. In the output shown above, the cpu spends most of its time in C3 - this is good.
The wakeups per second indicators are shown below the C states in the output of powertop. The lower the number, the better. For both the windows xp and Fedora guest, the wakeup per second was about 2500.
Reportedly, you can get wakeups per second as low as 3 running a full GNOME desktop. My laptop reported between 18 and 28 running no desktop at all ( booting to runlevel 3 ). With a full GNOME desktop on nvidia graphics card, my laptop reported between 18 and 28 wakeups per second.
Powertop displays the top ten causes for wakeups. For the windows xp guest, the top two causes of wakeups were due to kvm guest; sys_timer_settime and create_pit_timer . For the linux guest, only the top one reason was due to kvm guest; sys_timer_settime.
The last section of the output displays suggestions for improving your power efficiency.
What does your powertop output look like when running idle KVM guests? With and without virtio drivers? Windows vs Linux guests? Is your host running on AMD or intel? What are the top causes for your wakeups?
Comments
Interesting
Thursday, June 19, 2008 - 00:17 Avi Kivity (not verified)I don't see this here, running a Windows Server 2008 guest:
22.4% (122.2) : extra timer interrupt
17.8% ( 97.2) qemu-system-x86 : sys_timer_settime (posix_timer_fn)
14.8% ( 80.4) : Rescheduling interrupts
12.5% ( 67.9) : PS/2 keyboard/mouse/touchpad
9.7% ( 52.6) firefox : futex_wait (hrtimer_wakeup)
5.6% ( 30.4) : uhci_hcd:usb3, HDA Intel, iwl3945
3.3% ( 18.2) qemu-system-x86 : __kvm_migrate_pit_timer (pit_timer_fn)
2.3% ( 12.6) skype : schedule_timeout (process_timeout)
1.9% ( 10.5) : ata_piix
1.8% ( 10.0) skype : do_nanosleep (hrtimer_wakeup)
About 100 wakeups a second, as can be expected from a 100 Hz guest.
Can you post this on the mailing list, together with the command line used to start the guest?
Will post to mailing list
Thursday, June 19, 2008 - 00:53 Haydn SolomonSure thing Avi. Will post to the mailing list.
Post new comment