Skip to content


Subversion checkout URL

You can clone with
Download ZIP
The Linux PowerTOP tool -- please post patches to the mailing list instead of using github pull requests
C++ C Other
Latest commit 53370d9 Nivedita Swaminathan Fix crash due to unbounded string copies
Fix crash due to buffer overruns.
powertop does a lot of unsafe size-unchecked buffer copying.
Fix the easy ones.

Program received signal SIGABRT, Aborted.
0x00007ffff6513187 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
Missing separate debuginfos, use: zypper install libgcc_s1-gcc5-debuginfo-5.2.1+r228589-58.1.x86_64 libncurses5-debuginfo-5.9-52.2.3.x86_64 libnl3-200-debuginfo-3.2.25-2.1.2.x86_64 libpci3-debuginfo-3.2.1-3.1.2.x86_64 libstdc++6-gcc5-debuginfo-5.2.1+r228589-58.1.x86_64 libz1-debuginfo-1.2.8-5.1.2.x86_64
(gdb) up
78            raise (SIGABRT);
    fmt=fmt@entry=0x7ffff6640608 "*** %s ***: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:175
175           abort ();
    at fortify_fail.c:31
31          __libc_message (2, "*** %s ***: %s terminated\n",
28        __fortify_fail ("buffer overflow detected");
    at /usr/include/bits/string3.h:104
104       return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
    at process/process.cpp:92
92              strcpy(comm, _comm);
(gdb) ptyp comm
type = char [16]
(gdb) p comm
$1 = "poempp_2.21_x86_"
(gdb) ptyp _comm
type = const char *
(gdb) p _comm
$2 = 0xa2d6504 "poempp_2.21_x86_\214x"
(gdb) up
    at process/process.cpp:174
174             new_proc = new class process(comm, pid);
(gdb) p pid
$3 = 30860
(gdb) ^Z
[1]+  Stopped                 gdb /usr/sbin/powertop
12:16 ares40:../powertop/powertop # cat /proc/30860/stat
30860 (poempp_2.21_x86_64-pc-linux-gnu) R 9998 9998 9998 0 -1 4218880 9662 0 0 0 29182 44 0 0 39 19 2 0 1014983782 39407616 9490 18446744073709551615 4194304 8385953 140720786688848 140720786687224 5358714 0 0 4096 1073751144 18446744073709551615 0 0 17 4 0 3 0 0 0 10484880 10516168 37695488 140720786693790 140720786693855 140720786693855 140720786694071 0

Avoid hardcoding magic values when sizeof can be used.

Signed-off-by:Jan Engelhardt <>


Building & Installing PowerTOP

To build and install PowerTOP type the following commands, 
	./make install

Note: For Android (running Intel Architecture ) there is a 
that was provided by community members, and at this time is supported
 mostly by community members. 

Build dependencies

PowerTOP uses C++, and expects g++ and libstdc++ to be functional 
along with a glibc/pthreadsi, autoconf, automake, and libtool in the 
development environment.

in addition to that, PowerTOP requires the following components:

pciutils-devel (is only required if you have PCI) 
ncurses-devel  (required) 
libnl-devel    (required)
kernel version => 2.6.38

Build PowerTop for Android LollyPop

1. Obtain pciutils and ncurses libraries.
   Skip this step if they are already in the tree.

   pciutils: Clone
   into external/pciutils

   ncurses: Clone
   into external/ncurses

2. Run
       ./src/ src/powertop.css src/css.h
   to generate the css.h header file.

3. Apply patches inside patches/Android

4. PowerTop can be built with top level make,
   or by doing "mm".

   The resulting binary is under $ANDROID_PRODUCT_OUT/system/bin/powertop

Kernel Parameters:

PowerTOP needs some kernel config options enabled in order function properly.
As of linux-3.3.0 these are (list probably incomplete):


Use these configs from linux-3.13.rc1

The patches in the patches/ sub-directory are required for PowerTOP to function

Outputting a report
When invoking PowerTOP without arguments, PowerTOP starts in interactive mode.
However, for reporting bugs etc there is a special reporting modes:

For an HTML formatted report simply execute PowerTOP with the following,  

powertop --html

which will create a "powertop.html" file which is static and can be sent to
others to help diagnose power issues. Additionally has the feature of showing 
the tunables executions within the report as a reference. 

Note for the developers: If you make changes on the report format please
make sure that the output can be cleanly validated by the W3C Markup
Validation Service and W3C CSS Validation Service:

For a CSV formatted report, simply execute PowerTOP with the following, 

Powertop --csv 

which will create a “powertop.csv” file which is static and can be used in 
reporting, diagnoses, and analytical data analysis. 

Also you can set the number of iterations, and duration of test, in which case 
all reports will time stamp for you. 

Calibrating & Power Numbers
PowerTOP will, when running on battery, track your power consumption as well
as your activity on the system. Once there are sufficient such measurements,
PowerTOP can start to report power estimates for various activities.
You can help get this estimation more accurate by running a calibration

powertop --calibrate

at least once; this will cycle through various display brightness levels
(including "off") as well as USB device activities and some other workloads.

Code from other open source projects
PowerTOP contains some code from other open source projects; we'd like to
thank the authors of those projects for their work. 
Specifically PowerTOP contains code from

Parse Event Library - Copyright 2009, 2010 Red Hat Inc  Steven Rosted <>
nl80211 userspace tool - Copyright 2007, 2008	Johannes Berg <>

Extech Power Analyzer / Datalogger support
I use, and our analysis teams use, the Extech Power Analyzer/Datalogger
(model number 380803) quite a lot, and PowerTOP supports using this
device over the serial cable. Just pass the device node on the command line
like this

powertop --extech=/dev/ttyUSB0

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

Something went wrong with that request. Please try again.