PowerTOP is a Linux utility that can monitor and display a system's electrical power usage. It is useful as a hardware monitoring and diagnostic tool. It is among the most powerful battery stretching utilities for notebook computers.
Several kernel options must be enabled in the kernel for PowerTOP to work properly. These include: CONFIG_DEBUG_FS, CONFIG_TRACING, CONFIG_BLK_DEV_IO_TRACE, CONFIG_TIMER_STATS, CONFIG_CPU_FREQ_STAT, and CONFIG_CPU_FREQ_STAT_DETAILS.
CONFIG_TIMER_STATS has been removed from kernel, see https://patchwork.kernel.org/patch/9561519/
Optionally, for wireless power saving enable: CONFIG_TRACEPOINTS.
Power management and ACPI options ---> CPU Frequency scaling ---> [*] CPU Frequency scaling <*> CPU frequency translation statistics [*] CPU frequency translation statistics details [*] Extra PM attributes in sysfs for low-level debugging/testing Kernel hacking ---> Compile-time checks and compiler options ---> [*] Debug Filesystem [*] Kernel debugging [*] Collect kernel timers statistics [*] Tracers ---> [*] Support for tracing block IO actions
If the above options have not properly been enabled Portage will display warning messages at the end of the emerge. If help is required for upgrading the kernel while enabling the above options, be sure to see the kernel upgrade article!
USE flags for sys-power/powertop tool that helps you find what software is using the most power
After setting USE flags, emerge PowerTOP:
emerge --ask sys-power/powertop
PowerTOP does not have any configuration other than passing options via the command-line.
Calibration can be performed in order for PowerTOP to gain an understanding of the system:
Usage: powertop [OPTIONS] --auto-tune sets all tunable options to their GOOD setting -c, --calibrate runs powertop in calibration mode -C, --csv[=filename] generate a csv report --debug run in "debug" mode --extech[=devnode] uses an Extech Power Analyzer for measurements -r, --html[=filename] generate a html report -i, --iteration[=iterations] number of times to run each test -q, --quiet suppress stderr output -t, --time[=seconds] generate a report for 'x' seconds -w, --workload[=workload] file to execute for workload -V, --version print version information -h, --help print this help menu For more help please refer to the 'man 8 powertop'
Could not find a Makefile in the kernel source directory
After an emerge a message similar to the following message may be displayed:
* Could not find a Makefile in the kernel source directory. * Please ensure that /usr/src/linux points to a complete set of Linux sources * Unable to calculate Linux Kernel version for build, attempting to use running version * CONFIG_DEBUG_FS: is not set when it should be. * CONFIG_TRACEPOINTS: is not set when it should be. * CONFIG_BLK_DEV_IO_TRACE: is not set when it should be. * CONFIG_TIMER_STATS: is not set when it should be. * CONFIG_TRACING: is not set when it should be. * Please check to make sure these options are set correctly. * Failure to do so may cause unexpected problems.
This warning indicates the PowerTOP ebuild has attempted to verify a successful operating environment for the PowerTOP software package. In order to be sure PowerTOP will work as intended, at the end of the emerge process, a check is ran against the current kernel source configuration. In the case of the above message two warnings were provided:
- No kernel sources have been detected. This can happen as a result of running an emerge --depclean or failed to have a specific kernel set using the eselect kernel command.
- Since no kernel sources have been detected Portage was not able to scan the kernel's .config file to determine if the correct features have been enabled in the kernel. According to the error message above, five features are not set. The features may or may not be set in the current running kernel. Portage is simply making the user aware there is no way to verify these features have been set without a .config file. If PowerTOP can perform some functions but not others, be sure all the kernel features listed have been enabled. For more information on how to do so consult the kernel configuration article.
- https://www.linux.com/learn/powertop-finds-power-hogs-your-linux-pc - A Linux.com article on using PowerTOP to measure large power consumers.
- https://01.org/sites/default/files/page/powertop_users_guide_201406.pdf - A PowerTOP user guide writen by two Intel employees (PDF).