2.2. PowerTOP

The introduction of the tickless kernel in Red Hat Enterprise Linux 6 (refer to Section 3.6, “Tickless Kernel”) allows the CPU to enter the idle state more frequently, reducing power consumption and improving power management. The PowerTOP tool identifies specific components of kernel and userspace applications that frequently wake up the CPU. PowerTOP was used in development to perform the audits described in Section 3.13, “Optimizations in User Space” that led to many applications being tuned in this release, reducing unnecessary CPU wake up by a factor of ten.

Red Hat Enterprise Linux 6 comes with version 2.x of PowerTOP. This version is a complete rewrite of the 1.x codebase. It features a clearer tab-based user interface and extensively uses the kernel "perf" infrastructure to give more accurate data. The power behavior of system devices is tracked and prominently displayed, so problems can be pinpointed quickly. More experimentally, the 2.x codebase includes a power estimation engine that can indicate how much power individual devices and processes are consuming. Refer to Figure 2.1, “PowerTOP in Operation”.

To install PowerTOP run, as root, the following command:

yum install powertop

To run PowerTOP, execute the following command as root:

powertop

PowerTOP can provide an estimate of the total power usage of the system and show individual power usage for each process, device, kernel work, timer, and interrupt handler. Laptops should run on battery power during this task. To calibrate the power estimation engine, run, as root, the following command:

powertop --calibrate

Calibration takes time. The process performs various tests, and will cycle through brightness levels and switch devices on and off. Allow the process to finish and do not interact with the machine during the calibration. When it completes, PowerTOP starts as normal. Then keep PowerTOP running for approximately an hour to collect data. When enough data is collected, power estimation figures will be displayed in the first column.

If you are executing powertop --calibrate on a laptop, it should still be running on battery power so that all available data is presented.

While it runs, PowerTOP gathers statistics from the system. In the Overview tab, you can view a list of the components that are either sending wake-ups to the CPU most frequently or are consuming the most power (refer to Figure 2.1, “PowerTOP in Operation”). The adjacent columns display:

power estimation

how the resource is being used

wakeups per second

the classification of the component, such as process, device, or timer

description of the component

Wakeups per second indicates how efficiently the services or the devices and drivers of the kernel are performing. Less wakeups means less power is consumed. Components are ordered by how much further their power usage can be optimized.

Tuning driver components typically requires kernel changes, which is beyond the scope of this document. However, userland processes that send wakeups are more easily managed. First, determine whether this service or application needs to run at all on this system. If not, simply deactivate it. To turn off an old System V service permanently, run:

chkconfig servicename.service off

For more details about the process, run, as root, the following commands:

ps -awux | grep processnamestrace -p processid

If the trace looks like it is repeating itself, then it probably is a busy loop. Fixing such bugs typically requires a code change in that component.

As seen in Figure 2.1, “PowerTOP in Operation”, total power consumption and the remaining battery life are displayed, if applicable. Below these is a short summary featuring total wakeups per second, GPU operations per second, and virtual filesystem operations per second. In the rest of the screen there is a list of processes, interrupts, devices and other resources sorted according to their utilization. If properly calibrated, a power consumption estimation for every listed item in the first column is shown as well.

Use the Tab and Shift+Tab keys to cycle through tabs. In the Idle stats tab, use of C-states is shown for all processors and cores. In the Frequency stats tab, use of P-states including the Turbo mode (if applicable) is shown for all processors and cores. The longer the CPU stays in the higher C- or P-states, the better (C4 being higher than C3). This is a good indication of how well the CPU usage has been optimized. Residency should ideally be 90% or more in the highest C- or P-state while the system is idle.

The Device Stats tab provides similar information to the Overview tab but only for devices.

The Tunables tab contains suggestions for optimizing the system for lower power consumption. Use the up and down keys to move through suggestions and the enter key to toggle the suggestion on and off.

Figure 2.1. PowerTOP in Operation

You can also generate HTML reports by running PowerTOP with the --html option. Replace the htmlfile.html parameter with the desired name for the output file:

powertop --html=htmlfile.html

By default PowerTOP takes measurements in 20 seconds intervals, you can change it with the --time option:

PowerTOP can also be used along with the turbostat utility. It is a reporting tool that displays information about processor topology, frequency, idle power-state statistics, temperature, and power usage on Intel 64 processors. For more information about turbostat, refer to the turbostat man page, or the relevant section in Performance Tuning Guide.