PowerTOP

日系Linux5月号に「省電力対策」として、「PowerTOP」を使った調査方法があったので
試してみた〜。


インテルLinux向けにオープンソースで提供電力効率の悪いプログラムをリストアップする「PowerTOP」
http://www.atmarkit.co.jp/news/200707/26/powertop.html

PowerTOPのインストール
残念ながらyumでインストールとはならなったので、ソースから・・



[root@L2 bozu]# wget http://linuxpowertop.org/download/powertop-1.8.tar.gz

Resolving linuxpowertop.org... 204.253.143.234
Connecting to linuxpowertop.org|204.253.143.234|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 66947 (65K) [application/x-gzip]
Saving to: `powertop-1.8.tar.gz'

100%[==================================================>] 66,947 116K/s in 0.6s

2011-04-21 00:26:52 (116 KB/s) - `powertop-1.8.tar.gz' saved [66947/66947]

[root@L2 bozu]# tar xf ./powertop-1.8.tar.gz
[root@L2 bozu]# cd powertop-1.8

ここでコンパイルとなりますが、今回は「checkinstall」を使ってみたいと思います^^;

checkinstallのインストール


[root@L2 bozu]# wget http://asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1
.6.2.tar.gz

Resolving asic-linux.com.mx... 208.75.85.226
Connecting to asic-linux.com.mx|208.75.85.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 129577 (127K) [application/x-tar]
Saving to: `checkinstall-1.6.2.tar.gz'

100%[==================================================>] 129,577 59.3K/s in 2.1s

2011-04-21 00:37:43 (59.3 KB/s) - `checkinstall-1.6.2.tar.gz' saved [129577/129577]

[root@L2 bozu]# tar xf ./checkinstall-1.6.2.tar.gz

[root@L2 bozu]# cd checkinstall-1.6.2

[root@L2 checkinstall-1.6.2]# make
for file in locale/checkinstall-*.po ; do \
case ${file} in \
locale/checkinstall-template.po) ;; \
*) \
out=`echo $file | sed -s 's/po/mo/'` ; \
msgfmt -o ${out} ${file} ; \
if [ $? != 0 ] ; then \
exit 1 ; \
fi ; \
;; \
esac ; \
done
make -C installwatch
make[1]: Entering directory `/home/bozu/checkinstall-1.6.2/installwatch'
./create-localdecls
Checking truncate argument type... off_t
Checking readlinkat result type... ssize_t
Checking libc version... libc.so.6
Checking glibc subversion... gcc -Wall -c -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT -DVERSION=\"0.7.0beta7\" installwatch.c
ld -shared -o installwatch.so installwatch.o -ldl -lc
make[1]: Leaving directory `/home/bozu/checkinstall-1.6.2/installwatch'
[root@L2 checkinstall-1.6.2]# make install
for file in locale/checkinstall-*.po ; do \
case ${file} in \
locale/checkinstall-template.po) ;; \
*) \
out=`echo $file | sed -s 's/po/mo/'` ; \
msgfmt -o ${out} ${file} ; \
if [ $? != 0 ] ; then \
exit 1 ; \
fi ; \
;; \
esac ; \
done
make -C installwatch
make[1]: Entering directory `/home/bozu/checkinstall-1.6.2/installwatch'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/bozu/checkinstall-1.6.2/installwatch'
export
export CVS_RSH="ssh"
export G_BROKEN_FILENAMES="1"
export HISTSIZE="1000"
export HOME="/root"
export HOSTNAME="L2"
export INPUTRC="/etc/inputrc"
export LANG="en_US.UTF-8"
export LESSOPEN="|/usr/bin/lesspipe.sh %s"
export LOGNAME="bozu"
export LS_COLORS="no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:"
export MAIL="/var/spool/mail/bozu"
export MAKEFLAGS=""
export MAKELEVEL="1"
export MFLAGS=""
export OLDPWD
export PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/bozu/bin"
export PWD="/home/bozu/checkinstall-1.6.2"
export SHELL="/bin/bash"
export SHLVL="3"
export SSH_CLIENT="10.83.62.150 3601 22"
export SSH_CONNECTION="10.83.62.150 3601 10.83.62.202 22"
export SSH_TTY="/dev/pts/1"
export TERM="xterm"
export USER="bozu"
export _="/usr/bin/make"
make -C installwatch install
make[1]: Entering directory `/home/bozu/checkinstall-1.6.2/installwatch'
mkdir -p /usr/local/lib
mkdir -p /usr/local/bin
if [ -r /usr/local/lib/installwatch.so ]; then \
rm -f /usr/local/lib/installwatch.so; \
fi
install installwatch.so /usr/local/lib
sed -e "s|#PREFIX#|/usr/local|" < installwatch > /usr/local/bin/installwatch
chmod 755 /usr/local/bin/installwatch
make[1]: Leaving directory `/home/bozu/checkinstall-1.6.2/installwatch'
mkdir -p /usr/local/sbin
install checkinstall makepak /usr/local/sbin
for file in locale/*.mo ; do \
LANG=`echo $file | sed -e 's|locale/checkinstall-||' \
-e 's|\.mo||'` && \
mkdir -p /usr/local/lib/checkinstall/locale/${LANG}/LC_MESSAGES && \
cp $file /usr/local/lib/checkinstall/locale/${LANG}/LC_MESSAGES/checkinstall.mo || \
exit 1 ; \
done
mkdir -p /usr/local/lib/checkinstall
install -m644 checkinstallrc-dist /usr/local/lib/checkinstall
if ! [ -f /usr/local/lib/checkinstall/checkinstallrc ]; then \
cp /usr/local/lib/checkinstall/checkinstallrc-dist /usr/local/lib/checkinstall/checkinstallrc; \
else \
echo; \
echo; \
echo ======================================================== ;\
echo; \
echo An existing checkinstallrc file has been found. ;\
echo The one from this distribution can be found at: ; \
echo; \
echo -e \\t/usr/local/lib/checkinstall/checkinstallrc-dist ; \
echo; \
echo; \
echo ======================================================== ;\
echo; \
fi
[root@L2 checkinstall-1.6.2]#

さて、、、checkinstallをつかってRPMを作ります。


[root@L2 checkinstall-1.6.2]# cd ../powertop-1.8
[root@L2 powertop-1.8]# ./configure
bash: ./configure: No such file or directory
[root@L2 powertop-1.8]# ls
bluetooth.c COPYING display.c misctips.c powertop.c README usb.c
Changelog cpufreq.c ethernet.c po powertop.h sata.c wireless.c
config.c cpufreqstats.c Makefile powertop.1 process.c suggestions.c xrandr.c

Makeファイルはすでにあります。


[root@L2 powertop-1.8]# /usr/local/sbin/checkinstall

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.

The checkinstallrc file was not found at:
/usr/local/sbin/../checkinstallrc

Assuming default values.

The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:

Preparing package documentation...OK

Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? R


Please write a description for the package.
End your description with an empty line or EOF.

*************************************

*** RPM package creation selected ***

*************************************

This package will be built according to these values:

1 - Summary: [ Package created with checkinstall 1.6.2 ]
2 - Name: [ powertop ]
3 - Version: [ 1.8 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ powertop-1.8 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ powertop ]

Enter a number to change any of them or press ENTER to continue:

Installing with make install...

========================= Installation results ===========================
cc -Os -g -Wall -W -Wshadow -c -o powertop.o powertop.c
cc -Os -g -Wall -W -Wshadow -c -o config.o config.c
cc -Os -g -Wall -W -Wshadow -c -o process.o process.c
cc -Os -g -Wall -W -Wshadow -c -o misctips.o misctips.c
cc -Os -g -Wall -W -Wshadow -c -o bluetooth.o bluetooth.c
cc -Os -g -Wall -W -Wshadow -c -o display.o display.c
cc -Os -g -Wall -W -Wshadow -c -o suggestions.o suggestions.c
cc -Os -g -Wall -W -Wshadow -c -o wireless.o wireless.c
cc -Os -g -Wall -W -Wshadow -c -o cpufreq.o cpufreq.c
cc -Os -g -Wall -W -Wshadow -c -o sata.o sata.c
cc -Os -g -Wall -W -Wshadow -c -o xrandr.o xrandr.c
cc -Os -g -Wall -W -Wshadow -c -o ethernet.o ethernet.c
cc -Os -g -Wall -W -Wshadow -c -o cpufreqstats.o cpufreqstats.c
cc -Os -g -Wall -W -Wshadow -c -o usb.o usb.c
cc -Os -g -Wall -W -Wshadow powertop.o config.o process.o misctips.o bluetooth.o display.o suggestions.o wireless.o cpufreq.o sata.o xrandr.o ethernet.o cpufreqstats.o usb.o -lncursesw -o powertop
make[1]: Entering directory `/home/bozu/powertop-1.8/po'
make[1]: Leaving directory `/home/bozu/powertop-1.8/po'
gzip -c powertop.1 > powertop.1.gz
mkdir -p /usr/bin
cp powertop /usr/bin
mkdir -p /usr/share/man/man1
cp powertop.1.gz /usr/share/man/man1
make[1]: Entering directory `/home/bozu/powertop-1.8/po'
mkdir -p /usr/share/locale/de/LC_MESSAGES/
cp -f de.mo /usr/share/locale/de/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/es/LC_MESSAGES/
cp -f es.mo /usr/share/locale/es/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/fi/LC_MESSAGES/
cp -f fi.mo /usr/share/locale/fi/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/fr/LC_MESSAGES/
cp -f fr.mo /usr/share/locale/fr/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/hu/LC_MESSAGES/
cp -f hu.mo /usr/share/locale/hu/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/id/LC_MESSAGES/
cp -f id.mo /usr/share/locale/id/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/it/LC_MESSAGES/
cp -f it.mo /usr/share/locale/it/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/ja/LC_MESSAGES/
cp -f ja.mo /usr/share/locale/ja/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/nl/LC_MESSAGES/
cp -f nl.mo /usr/share/locale/nl/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/pl/LC_MESSAGES/
cp -f pl.mo /usr/share/locale/pl/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/pt_BR/LC_MESSAGES/
cp -f pt_BR.mo /usr/share/locale/pt_BR/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/ru/LC_MESSAGES/
cp -f ru.mo /usr/share/locale/ru/LC_MESSAGES/powertop.mo
mkdir -p /usr/share/locale/zh/LC_MESSAGES/
cp -f zh.mo /usr/share/locale/zh/LC_MESSAGES/powertop.mo
make[1]: Leaving directory `/home/bozu/powertop-1.8/po'

======================== Installation successful ==========================

Copying documentation directory...
./
./COPYING
./Changelog
./README

Copying files to the temporary directory...OK

Stripping ELF binaries...OK

Compressing man pages...OK

Building file list...OK

Building RPM package...OK

NOTE: The package will not be installed

Erasing temporary files...OK

Deleting doc-pak directory...OK

Writing backup package...OK
OK

Deleting temp dir...OK

*********************************************************************

Done. The new package has been saved to

/usr/src/redhat/RPMS/i386/powertop-1.8-1.i386.rpm
You can install it in your system anytime using:

rpm -i powertop-1.8-1.i386.rpm

*********************************************************************

できました♪


[root@L2 powertop-1.8]# rpm -ivh //usr/src/redhat/RPMS/i386/powertop-1.8-1.i386.rpm
Preparing... ########################################### [100%]
1:powertop ########################################### [100%]
[root@L2 powertop-1.8]#

インストール完了♪
スゲー楽だ。これならアンインストールも楽だし、、いいっすねぇ^^;

で肝心のPowerTOPを起動してみる。。。


[root@L2 powertop-1.8]# powertop


Cn Avg residency P-states (frequencies)
C0 (cpu running) ( 5.4%)
C1 0.0ms ( 0.0%)
C2 0.8ms ( 9.7%)
C3 1.0ms (84.9%)


Wakeups-from-idle per second : 1005.5 interval: 10.0s
no ACPI power usage estimate available

No detailed statistics available; please enable the CONFIG_TIMER_STATS kernel option
This option is located in the Kernel Debugging section of menuconfig
(which is CONFIG_DEBUG_KERNEL=y in the config file)
Note: this is only available in 2.6.21 and later kernels





Suggestion: increase the VM dirty writeback time from 4.99 to 15 seconds with:
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
This wakes the disk up less frequenty for background VM activity
Q - Quit R - Refresh W - Increase Writeback time

ま、まぁよくわからないけど(汗)