Chapter 15. Managing power consumption with PowerTOP
As a system administrator, you can use the PowerTOP tool to analyze and manage power consumption.
15.1. The purpose of PowerTOP
PowerTOP is a program that diagnoses issues related to power consumption and provides suggestions on how to extend battery lifetime.
The PowerTOP tool can provide an estimate of the total power usage of the system and also individual power usage for each process, device, kernel worker, timer, and interrupt handler. The tool can also identify specific components of kernel and user-space applications that frequently wake up the CPU.
Red Hat Enterprise Linux 9 uses version 2.x of PowerTOP.
15.2. Using PowerTOP
To be able to use PowerTOP, make sure that the
powertoppackage has been installed on your system:
# dnf install powertop
15.2.1. Starting PowerTOP
To run PowerTOP, use the following command:
Laptops should run on battery power when running the
15.2.2. Calibrating PowerTOP
On a laptop, you can calibrate the power estimation engine by running the following command:
# powertop --calibrate
Let the calibration finish without interacting with the machine during the process.
Calibration takes time because the process performs various tests, cycles through brightness levels and switches devices on and off.
When the calibration process is completed, PowerTOP starts as normal. Let it run for approximately an hour to collect data.
When enough data is collected, power estimation figures will be displayed in the first column of the output table.
powertop --calibrate can only be used on laptops.
15.2.3. Setting the measuring interval
By default, PowerTOP takes measurements in 20 seconds intervals.
If you want to change this measuring frequency, use the following procedure:
powertopcommand with the
# powertop --time=time in seconds
15.2.4. Additional resources
For more details on how to use PowerTOP, see the
powertop man page.
15.3. PowerTOP statistics
While it runs, PowerTOP gathers statistics from the system.
PowerTOP's output provides multiple tabs:
You can use the
Shift+Tab keys to cycle through these tabs.
15.3.1. The Overview tab
Overview tab, you can view a list of the components that either send wakeups to the CPU most frequently or consume the most power. The items within the
Overview tab, including processes, interrupts, devices, and other resources, are sorted according to their utilization.
The adjacent columns within the
Overview tab provide the following pieces of information:
- Power estimation of how the resource is being used.
- Wakeups per second. The number of wakeups per second indicates how efficiently the services or the devices and drivers of the kernel are performing. Less wakeups means that less power is consumed. Components are ordered by how much further their power usage can be optimized.
- Classification of the component; such as process, device, or timer.
- Description of the component.
If properly calibrated, a power consumption estimation for every listed item in the first column is shown as well.
Apart from this, the
Overview tab includes the line with summary statistics such as:
- Total power consumption
- Remaining battery life (only if applicable)
- Summary of total wakeups per second, GPU operations per second, and virtual file system operations per second
15.3.2. The Idle stats tab
Idle stats tab shows usage of C-states for all processors and cores, while the
Frequency stats tab shows usage of P-states including the Turbo mode, if applicable, for all processors and cores. The duration of C- or P-states is an indication of how well the CPU usage has been optimized. The longer the CPU stays in the higher C- or P-states (for example C4 is higher than C3), the better the CPU usage optimization is. Ideally, residency is 90% or more in the highest C- or P-state when the system is idle.
15.3.3. The Device stats tab
Device stats tab provides similar information to the
Overview tab but only for devices.
15.3.4. The Tunables tab
Tunables tab contains PowerTOP's suggestions for optimizing the system for lower power consumption.
down keys to move through suggestions, and the
enter key to toggle the suggestion on or off.
15.3.5. The WakeUp tab
WakeUp tab displays the device wakeup settings available for users to change as and when required.
down keys to move through the available settings, and the
enter key to enable or disable a setting.
Figure 15.1. PowerTOP output
For more details on PowerTOP, see PowerTOP’s home page.
15.4. Why Powertop does not display Frequency stats values in some instances
While using the Intel P-State driver, PowerTOP only displays values in the
Frequency Stats tab if the driver is in passive mode. But, even in this case, the values may be incomplete.
In total, there are three possible modes of the Intel P-State driver:
- Active mode with Hardware P-States (HWP)
- Active mode without HWP
- Passive mode
Switching to the ACPI CPUfreq driver results in complete information being displayed by PowerTOP. However, it is recommended to keep your system on the default settings.
To see what driver is loaded and in what mode, run:
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
intel_pstateis returned if the Intel P-State driver is loaded and in active mode.
intel_cpufreqis returned if the Intel P-State driver is loaded and in passive mode.
acpi-cpufreqis returned if the ACPI CPUfreq driver is loaded.
While using the Intel P-State driver, add the following argument to the kernel boot command line to force the driver to run in passive mode:
To disable the Intel P-State driver and use, instead, the ACPI CPUfreq driver, add the following argument to the kernel boot command line:
15.5. Generating an HTML output
Apart from the
powertop’s output in terminal, you can also generate an HTML report.
powertopcommand with the
# powertop --html=htmlfile.html
htmlfile.htmlparameter with the required name for the output file.
15.6. Optimizing power consumption
To optimize power consumption, you can use either the
powertop service or the
15.6.1. Optimizing power consumption using the powertop service
You can use the
powertop service to automatically enable all PowerTOP's suggestions from the
Tunables tab on the boot:
# systemctl enable powertop
15.6.2. The powertop2tuned utility
powertop2tuned utility allows you to create custom TuneD profiles from PowerTOP suggestions.
powertop2tuned creates profiles in the
/etc/tuned/ directory, and bases the custom profile on the currently selected TuneD profile. For safety reasons, all PowerTOP tunings are initially disabled in the new profile.
To enable the tunings, you can:
Uncomment them in the
-eoption to generate a new profile that enables most of the tunings suggested by PowerTOP.
Certain potentially problematic tunings, such as the USB autosuspend, are disabled by default and need to be uncommented manually.
15.6.3. Optimizing power consumption using the powertop2tuned utility
powertop2tunedutility is installed on the system:
# dnf install tuned-utils
Create a custom profile:
# powertop2tuned new_profile_name
Activate the new profile:
# tuned-adm profile new_profile_name
For a complete list of options that
$ powertop2tuned --help
15.6.4. Comparison of powertop.service and powertop2tuned
Optimizing power consumption with
powertop2tuned is preferred over
powertop.service for the following reasons:
powertop2tunedutility represents integration of PowerTOP into TuneD, which enables to benefit of advantages of both tools.
powertop2tunedutility allows for fine-grained control of enabled tuning.
powertop2tuned, potentially dangerous tuning are not automatically enabled.
powertop2tuned, rollback is possible without reboot.