Este contenido no está disponible en el idioma seleccionado.
Chapter 17. Managing power consumption with PowerTOP
As a system administrator, you can use the PowerTOP tool to analyze and manage power consumption.
17.1. The purpose of PowerTOP Copiar enlaceEnlace copiado en el portapapeles!
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.
17.2. Using PowerTOP Copiar enlaceEnlace copiado en el portapapeles!
Prerequisites
To be able to use PowerTOP, make sure that the
powertoppackage has been installed on your system:dnf install powertop
# dnf install powertopCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.2.1. Starting PowerTOP Copiar enlaceEnlace copiado en el portapapeles!
Procedure
To run PowerTOP, use the following command:
powertop
# powertopCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Laptops should run on battery power when running the powertop command.
17.2.2. Calibrating PowerTOP Copiar enlaceEnlace copiado en el portapapeles!
Procedure
On a laptop, you can calibrate the power estimation engine by running the following command:
powertop --calibrate
# powertop --calibrateCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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.
Note that powertop --calibrate can only be used on laptops.
17.2.3. Setting the measuring interval Copiar enlaceEnlace copiado en el portapapeles!
By default, PowerTOP takes measurements in 20 seconds intervals.
If you want to change this measuring frequency, use the following procedure:
Procedure
Run the
powertopcommand with the--timeoption:powertop --time=time in seconds
# powertop --time=time in secondsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.3. PowerTOP statistics Copiar enlaceEnlace copiado en el portapapeles!
While it runs, PowerTOP gathers statistics from the system.
PowerTOP's output provides multiple tabs:
-
Overview -
Idle stats -
Frequency stats -
Device stats -
Tunables -
WakeUp
You can use the Tab and Shift+Tab keys to cycle through these tabs.
17.3.1. The Overview tab Copiar enlaceEnlace copiado en el portapapeles!
In the 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:
- Usage
- Power estimation of how the resource is being used.
- Events/s
- 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.
- Category
- Classification of the component; such as process, device, or timer.
- Description
- 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
17.3.2. The Idle stats tab Copiar enlaceEnlace copiado en el portapapeles!
The 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.
17.3.3. The Device stats tab Copiar enlaceEnlace copiado en el portapapeles!
The Device stats tab provides similar information to the Overview tab but only for devices.
17.3.4. The Tunables tab Copiar enlaceEnlace copiado en el portapapeles!
The Tunables tab contains PowerTOP's 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 or off.
17.3.5. The WakeUp tab Copiar enlaceEnlace copiado en el portapapeles!
The WakeUp tab displays the device wakeup settings available for users to change as and when required.
Use the up and down keys to move through the available settings, and the enter key to enable or disable a setting.
Figure 17.1. PowerTOP output
17.4. Why Powertop does not display Frequency stats values in some instances Copiar enlaceEnlace copiado en el portapapeles!
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
# 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:
intel_pstate=passive
intel_pstate=passive
To disable the Intel P-State driver and use, instead, the ACPI CPUfreq driver, add the following argument to the kernel boot command line:
intel_pstate=disable
intel_pstate=disable
17.5. Generating an HTML output Copiar enlaceEnlace copiado en el portapapeles!
Apart from the powertop’s output in terminal, you can also generate an HTML report.
Procedure
Run the
powertopcommand with the--htmloption:powertop --html=htmlfile.html
# powertop --html=htmlfile.htmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the
htmlfile.htmlparameter with the required name for the output file.
17.6. Optimizing power consumption Copiar enlaceEnlace copiado en el portapapeles!
To optimize power consumption, you can use either the powertop service or the powertop2tuned utility.
17.6.1. Optimizing power consumption using the powertop service Copiar enlaceEnlace copiado en el portapapeles!
You can use the powertop service to automatically enable all PowerTOP's suggestions from the Tunables tab on the boot:
Procedure
Enable the
powertopservice:systemctl enable powertop
# systemctl enable powertopCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.6.2. The powertop2tuned utility Copiar enlaceEnlace copiado en el portapapeles!
The powertop2tuned utility allows you to create custom TuneD profiles from PowerTOP suggestions.
By default, 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
/etc/tuned/profile_name/tuned.conf file. Use the
--enableor-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.
17.6.3. Optimizing power consumption using the powertop2tuned utility Copiar enlaceEnlace copiado en el portapapeles!
Prerequisites
The
powertop2tunedutility is installed on the system:dnf install tuned-utils
# dnf install tuned-utilsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Create a custom profile:
powertop2tuned new_profile_name
# powertop2tuned new_profile_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Activate the new profile:
tuned-adm profile new_profile_name
# tuned-adm profile new_profile_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
For a complete list of options that
powertop2tunedsupports, use:powertop2tuned --help
$ powertop2tuned --helpCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.6.4. Comparison of powertop.service and powertop2tuned Copiar enlaceEnlace copiado en el portapapeles!
Optimizing power consumption with powertop2tuned is preferred over powertop.service for the following reasons:
-
The
powertop2tunedutility represents integration of PowerTOP into TuneD, which enables to benefit of advantages of both tools. -
The
powertop2tunedutility allows for fine-grained control of enabled tuning. -
With
powertop2tuned, potentially dangerous tuning are not automatically enabled. -
With
powertop2tuned, rollback is possible without reboot.