Chapter 9. Managing power consumption with PowerTOP
Reducing the overall power consumption of computer systems helps to save cost. Effectively optimizing energy consumption of each system component includes studying different tasks that your system performs, and configuring each component to ensure that its performance is correct for that job. Lowering the power consumption of a specific component or of the system as a whole leads to lower heat and performance.
Proper power management results in:
- Heat reduction for servers and computing centers.
- Reduced secondary costs, including cooling, space, cables, generators, and uninterruptible power supplies (UPS).
- Extended battery life for laptops.
- Lower carbon dioxide output.
- Meeting government regulations or legal requirements regarding Green IT, for example, Energy Star.
- Meeting company guidelines for new systems.
9.1. Power management basics Copy linkLink copied to clipboard!
Effective power management is built on the following principles:
- An idle CPU should only wake up when needed
Since Red Hat Enterprise Linux 6, the kernel runs tickless, which means the previous periodic timer interrupts have been replaced with on-demand interrupts. Therefore, idle CPUs are allowed to remain idle until a new task is queued for processing, and CPUs that have entered lower power states can remain in these states longer. However, benefits from this feature can be offset if your system has applications that create unnecessary timer events. Polling events, such as checks for volume changes or mouse movement, are examples of such events.
Red Hat Enterprise Linux includes tools to identify and audit applications on the basis of their CPU usage. For details, see Audit and analysis overview and Tools for auditing.
- Unused hardware and devices should be disabled completely
- This is true for devices that have moving parts, for example, hard disks. In addition, some applications may leave an unused but enabled device "open". When this occurs, the kernel assumes that the device is in use, which can prevent the device from going into a power saving state.
- Low activity should translate to low wattage
- Power efficiency often depends on modern hardware and proper BIOS or UEFI configuration, especially on non-x86 architectures. Ensure that your system is running the latest official firmware, and that power management features are enabled in the BIOS or device configuration settings.
Some features to look for include:
- Collaborative Processor Performance Controls (CPPC) support for ARM64
- PowerNV support for IBM Power Systems
- Cool’n’Quiet
- ACPI (C-state)
- Smart
If your hardware has support for these features and they are enabled in the BIOS, Red Hat Enterprise Linux uses them by default.
- Different forms of CPU states and their effects
Modern CPUs together with Advanced Configuration and Power Interface (ACPI) provide different power states. The three different states are:
- Sleep (C-states)
- Frequency and voltage (P-states)
Heat output (T-states or thermal states)
A CPU running on the lowest sleep state consumes the least amount of energy, but it also takes considerably more time to wake it up from that state when needed. In very rare cases this can lead to the CPU having to wake up immediately every time it just went to sleep. This situation results in an effectively permanently busy CPU and loses some of the potential power saving if another state had been used.
- A turned off machine uses the least amount of power
- One of the best ways to save power is to turn off systems. For example, your company can develop a corporate culture focused on "green IT" awareness with a guideline to turn off machines during lunch break or when going home. You also might consolidate several physical servers into one bigger server and virtualize them using the virtualization technology, which is shipped with Red Hat Enterprise Linux.
9.2. Audit and analysis overview Copy linkLink copied to clipboard!
The detailed manual audit, analysis, and tuning of a single system is usually the exception because the time and cost spent to do so typically outweighs the benefits gained from these last pieces of system tuning. However, performing these tasks once for a large number of nearly identical systems where you can reuse the same settings for all systems can be very useful. For example, consider the deployment of thousands of desktop systems, or an HPC cluster where the machines are nearly identical. Another reason for auditing and analysis is to provide a basis for comparison against which you can identify regressions or changes in system behavior in the future. The results of this analysis can be very helpful in cases where hardware, BIOS, or software updates happen regularly and you want to avoid any surprises with regard to power consumption. Generally, a thorough audit and analysis gives you a much better idea of what is really happening on a particular system.
Auditing and analyzing a system with regard to power consumption is relatively hard, even with the most modern systems available. Most systems do not provide the necessary means to measure power use by using software. Exceptions exist though:
- iLO management console of Hewlett Packard server systems has a power management module that you can access through the web.
- IBM provides a similar solution in their BladeCenter power management module.
- On some Dell systems, the IT Assistant offers power monitoring capabilities.
Other vendors are likely to offer similar capabilities for their server platforms, but there is no single solution available that is supported by all vendors.
9.3. Tools for auditing Copy linkLink copied to clipboard!
Red Hat Enterprise Linux offers tools for system auditing and analysis. Most of them can be used as supplementary sources of information when you want to verify what you have discovered already or when you need more in-depth information about certain parts. Many of these tools are used for performance tuning, which include:
- PowerTOP
-
PowerTOP identifies specific components of kernel and user-space applications that frequently wake up the CPU. Intel CPU’s Intel Hardware P-State (HWP) adjusts CPU frequency and voltage to regulate the power efficiency and performance. You can use the
powertop
command as root to start the PowerTOP tool andpowertop --calibrate
to calibrate the power estimation engine. diskdevstat
andnetdevstat
These are SystemTap tools that collect detailed information about the disk and network activity of all applications running on a system. Using the collected statistics by these tools, you can identify applications that waste power with many small I/O operations rather than fewer, larger operations. Using the
dnf install tuned-utils-systemtap kernel-debuginfo
command as root, installs thediskdevstat
andnetdevstat
tools. To view detailed information about the disk and network activity, use:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow With these commands, you can specify three parameters:
update_interval
,total_duration
, anddisplay_histogram
.- TuneD
-
It is a profile-based system tuning tool that uses the
udev
device manager to monitor connected devices, and enables both static and dynamic tuning of system settings. You can use thetuned-adm recommend
command to determine which profile Red Hat suggests as the most suitable for a particular product. For details about TuneD, see Optimizing system performance with TuneD. Using thepowertop2tuned
utility, you can create custom TuneD profiles from PowerTOP suggestions. For details about thepowertop2tuned
utility, see Optimizing power consumption. - Virtual memory statistics (
vmstat
) A tool provided by the
procps-ng
package that you can use to view the detailed information about processes, memory, paging, block I/O, traps, and CPU activity. You can use the following command to view this information:vmstat
$ vmstat procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 0 0 5805576 380856 4852848 0 0 119 73 814 640 2 2 96 0 0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow View the active and inactive memory by using the
vmstat -a
command.iostat
Provided by the
sysstat
package, this tool is similar tovmstat
, but only for monitoring I/O on block devices. It provides more verbose output and statistics. You can use the following command to monitor the system I/O:Copy to Clipboard Copied! Toggle word wrap Toggle overflow blktrace
Provides detailed information about how time is spent in the I/O subsystem. You can use the following command to view this information in human readable format:
blktrace -d /dev/dm-0 -o - | blkparse -i -
# blktrace -d /dev/dm-0 -o - | blkparse -i - 253,0 1 1 0.000000000 17694 Q W 76423384 + 8 [kworker/u16:1] 253,0 2 1 0.001926913 0 C W 76423384 + 8 [0] [...]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The first column,
253,0
is the device major and minor tuple. The second column,1
, gives information about the CPU, followed by columns fortimestamps
andPID
of the process issuing the IO process. The sixth column,Q
, shows the event type, the 7th column,W
for write operation, the 8th column,76423384
, is the block number, and the+ 8
is the number of requested blocks. The last field,[kworker/u16:1]
, is the process name. By default, theblktrace
command runs forever until the process is explicitly killed. You can use the-w
option to specify the run-time duration.turbostat
It is provided by the
kernel-tools
package. It reports on processor topology, frequency, idle power-state statistics, temperature, and power usage on x86-64 processors. You can use the following command to view the summary:Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default,
turbostat
prints a summary of counter results for the entire screen, followed by counter results every 5 seconds. Specify a different period between counter results with the-i
option, for example, execute turbostat-i 10
to print results every10
seconds instead.turbostat
is also useful for identifying servers that are inefficient in terms of power usage or idle time. It also helps to identify the rate of system management interrupts (SMIs) occurring on the system. It can also be used to verify the effects of power management tuning.cpupower
The
cpupower
package contains a collection of tools to examine and tune power saving related features of processors. You can use thecpupower
command with thefrequency-info
,frequency-set
,idle-info
,idle-set
,set
,info
, and monitor options to display and set processor related values.For example, to view available
cpufreq
governors, use:cpupower frequency-info --governors
$ cpupower frequency-info --governors analyzing CPU 0: available cpufreq governors: performance powersave
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - GNOME Power Manager
- It is a daemon that is installed as part of the GNOME desktop environment. GNOME Power Manager notifies you of changes in your system’s power status, for example, a change from battery to AC power. It also reports battery status, and warns you when battery power is low.
pmda-denki
-
pmda-denki
monitors power consumption. It’s part of the Performance Co-Pilot suite, and helps to monitor consumption over time, and visualize it. For details, see Take control of your RHEL systems’ power consumption with pmda-denki.
9.4. The purpose of PowerTOP Copy linkLink copied to clipboard!
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 uses version 2.x of PowerTOP.
9.5. Installing PowerTOP Copy linkLink copied to clipboard!
You can install PowerTop and start using it to diagnose issues related to power consumption.
Procedure
Open the terminal and enter:
dnf install powertop
# dnf install powertop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.6. Starting PowerTOP Copy linkLink copied to clipboard!
After you install it on your system, you can start using PowerTop.
Prerequisites
- You are running your laptop on battery power.
Procedure
To run PowerTOP, use the following command:
powertop
# powertop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.7. Calibrating PowerTOP Copy linkLink copied to clipboard!
You can use the PowerTOP calibration process to improve the accuracy of power consumption measurements on your laptop.
Procedure
On a laptop, you can calibrate the power estimation engine by running the following command:
powertop --calibrate
# powertop --calibrate
Copy 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.
9.8. Setting the measuring interval Copy linkLink copied to clipboard!
By default, PowerTOP takes measurements in 20 seconds intervals. But, you can change this measuring frequency based on your requirements.
Procedure
To change the measuring frequency, run the
powertop
command with the--time
option:powertop --time=<time_in_seconds>
# powertop --time=<time_in_seconds>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.9. Controlling CPU frequency drivers and modes Copy linkLink copied to clipboard!
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 can 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.
Procedure
View what driver is loaded and in what mode:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - intel_pstate is returned if the Intel P-State driver is loaded and in active mode.
- intel_cpufreq is returned if the Intel P-State driver is loaded and in passive mode.
- acpi-cpufreq is 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
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To disable the Intel P-State driver and use the ACPI CPUfreq driver, add the following argument to the kernel boot command line:
intel_pstate=disable
intel_pstate=disable
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.10. Generating an HTML output Copy linkLink copied to clipboard!
You can also generate an HTML report apart from the powertop’s output in the terminal.
Procedure
Run the
powertop
command with the--html
option:powertop --html=<htmlfile.html>
# powertop --html=<htmlfile.html>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the <htmlfile.html> parameter with the required name for the output file.
9.11. Optimizing power consumption Copy linkLink copied to clipboard!
You can use either the powertop
service or the powertop2tuned
utility to optimize power consumption.
9.11.1. Optimizing power consumption using the powertop service Copy linkLink copied to clipboard!
You can use the powertop
service to automatically enable all PowerTOP’s suggestions from the Tunables tab on the boot.
Procedure
Enable the
powertop
service:systemctl enable powertop
# systemctl enable powertop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.11.2. The powertop2tuned utility Copy linkLink copied to clipboard!
Use the powertop2tuned
utility 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. You can enable the tunings by uncommenting them in the /etc/tuned/profiles/profile_name/tuned.conf
file.
Use the --enable
or -e
option 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.
9.11.3. Optimizing power consumption using the powertop2tuned utility Copy linkLink copied to clipboard!
You can use the powertop2tuned
utility to generate a custom TuneD profile that helps optimize your system’s power consumption.
Prerequisites
The
powertop2tuned
utility is installed on the system.dnf install tuned-utils
# dnf install tuned-utils
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Create a custom profile:
powertop2tuned <new_profile_name>
# powertop2tuned <new_profile_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Activate the new profile:
tuned-adm profile <new_profile_name>
# tuned-adm profile <new_profile_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.11.4. Comparing powertop2tuned and powertop.service usage Copy linkLink copied to clipboard!
You can prefer optimizing power consumption with powertop2tuned
over powertop.service
for the following reasons:
-
The
powertop2tuned
utility represents integration of PowerTOP into TuneD, which enables the benefit of both tools. -
The
powertop2tuned
utility allows for fine-grained control of enabled tuning. -
With
powertop2tuned
, potentially dangerous tuning is not automatically enabled. -
With
powertop2tuned
, rollback is possible without reboot.