Total Pageviews

Saturday 27 May 2023

Linux下开源的电源管理软件PowerTOP



PowerTOP是 Intel公司开源的Linux下电源管理/诊断工具,主要支持Intel架构的笔记本电脑。通过查看系统中软件应用的活跃程度, 诊断功耗,找出那些耗电量大的程序,通过修复或者关闭那些应用程序或进程,从而为用户节省电源。

Ubuntu 用户安装命令:

sudo add-apt-repository ppa:tsvetko.tsvetkov/trusty-backports
sudo apt-get update
sudo apt-get install powertop

卸载命令:

sudo apt-get remove powertop

OpenSUSE  用户安装命令:

sudo wget http://download.opensuse.org/repositories/home:/happenpappen/openSUSE_13.1/home:happenpappen.repo -O /etc/zypp/repos.d/home:happenpappen.repo
sudo zypper refresh
sudo zypper install powertop

-------------------------------------

The Linux PowerTOP tool.

PowerTOP

PowerTOP is a Linux* tool used to diagnose issues with power consumption and power management. In addition to being a diagnostic tool, PowerTOP also has an interactive mode you can use to experiment with various power management settings, for cases where the Linux distribution has not enabled those settings.

Build dependencies

PowerTOP is coded in C++. It was written for Linux-based operating systems. GNU* libc (glibc) and Linux pthreads are needed for PowerTOP to function properly. The GNU build system (autoconf, automake, make, libtool), as well as gettext, are required to build PowerTOP.

In addition, PowerTOP requires the following:

  • kernel version => 2.6.38
  • ncurses-devel (required)
  • libnl-devel (required)
  • pciutils-devel (is only required if you have PCI)
  • autoconf-archive (for building)

Example packages to install in Ubuntu*:

sudo apt install libpci-dev libnl-3-dev libnl-genl-3-dev gettext \
libgettextpo-dev autopoint gettext libncurses5-dev libncursesw5-dev libtool-bin \
dh-autoreconf autoconf-archive pkg-config

Building PowerTOP

The autogen.sh script needs to be run only once to generate configure. You need to re-run it only if the build system configuration files (e.g. configure.ac) are modified. The remaining steps are required whenever source files are modified.

To build PowerTOP from the cloned source, use the following commands:

./autogen.sh
./configure
make

Running PowerTOP

The following sections go over basic operation of PowerTOP. This includes kernel configuration options (or kernel patches) needed for full functionality. Run powertop --help to see all options.

Kernel parameters and (optional) patches

PowerTOP needs some kernel config options enabled to function properly. As of linux-3.3.0, these are (the list probably is incomplete):

CONFIG_NO_HZ
CONFIG_HIGH_RES_TIMERS
CONFIG_HPET_TIMER
CONFIG_CPU_FREQ_GOV_ONDEMAND
CONFIG_USB_SUSPEND
CONFIG_SND_AC97_POWER_SAVE
CONFIG_TIMER_STATS
CONFIG_PERF_EVENTS
CONFIG_PERF_COUNTERS
CONFIG_TRACEPOINTS
CONFIG_TRACING
CONFIG_EVENT_POWER_TRACING_DEPRECATED
CONFIG_X86_MSR
ACPI_PROCFS_POWER
CONFIG_DEBUG_FS

Use these configs from linux-3.13.rc1:

CONFIG_POWERCAP
CONFIG_INTEL_RAPL

The patches in the patches/ sub-directory are optional but enable full PowerTOP functionality.

Outputting a report

When PowerTOP is executed as root and without arguments, it runs in interactive mode. In this mode, PowerTOP most resembles top.

For generating reports, or for filing functional bug reports, there are two output modes: CSV and HTML. You can set sample times, the number of iterations, a workload over which to run PowerTOP, and whether to include debug-level output.

For an HTML report, execute PowerTOP with this option:

powertop --html=report.html

This creates a static report.html file, suitable for sharing.

For a CSV report, execute PowerTOP with this option:

powertop --csv=report.csv

This creates a static powertop.csv file, also suitable for sharing.

If you wish to file a functional bug report, generate and share a debug-mode HTML report and share it, using the following command:

powertop --debug --html=report.html

Important Note: As PowerTOP is intended for privileged (root) use, your reports-- especially when run with --debug-- will contain verbose system information. PowerTOP does not sanitize, scrub, or otherwise anonymize its reports. Be mindful of this when sharing reports.

Developers: If you make changes to the HTML reporting code, validate HTML output by using the W3C* Markup Validation Service and the W3C CSS Validation Service:

Calibrating and power numbers

PowerTOP, when running on battery, tracks power consumption and activity on the system. Once there are sufficient measurements, PowerTOP can start to report power estimates for various activities. You can help increase the accuracy of the estimation by running a calibration cycle at least once:

powertop --calibrate

Calibration entails cycling through various display brightness levels (including "off"), USB device activities, and other workloads.

Extech Power Analyzer / Datalogger support

Our analysis teams use the Extech* Power Analyzer/Datalogger (model number 380803). PowerTOP supports this device over the serial cable by passing the device node on the command line using this command:

powertop --extech=/dev/ttyUSB0

(where ttyUSB0 is the devicenode of the serial-to-usb adapter on our system)

from https://github.com/fenrus75/powertop

(https://github.com/fenrus75/powertop/releases/download/v2.15/powertop.tar.gz)

 

No comments:

Post a Comment