ゼロスピンドル Let's note W2 で Debian 4.0 Etch
http://d.hatena.ne.jp/sa-y/20070803 の続き.やる気のない設定ログ.
CPU クロックを動的に
せっかくノートPCで Pentium M な CPU なのでバッテリーの持ちをよくさせるためにもクロックを動的に変更するように設定したいです.最近の Linux では cpufreqd とかじゃなくてカーネルドライバでできるらしいですよ奥さん.
とりあえずスピードステップのドライバをロードしてみます.W2 は centrino らしいのでそのようにします.
% modprobe speedstep-centrino
動作モードや設定の変更は cpufrequtils パッケージの cpufreq-set と cpufreq-info コマンドで行なうらしいです.入ってなかったらインストールしましょう.とりあえず cpufreq-info で現状を表示してみます.
% cpufreq-info cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006 Report errors and bugs to linux@brodo.de, please. analyzing CPU 0: driver: centrino CPUs which need to switch frequency at the same time: 0 hardware limits: 600 MHz - 1.10 GHz available frequency steps: 1.10 GHz, 1000 MHz, 900 MHz, 800 MHz, 600 MHz available cpufreq governors: performance current policy: frequency should be within 600 MHz and 1.10 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 1.10 GHz (asserted by call to hardware).
current CPU frequency is 1.10 GHz ってことなのでCPUは最大速度で動いちゃってるようですね.この辺の内容は /sys/devices/system/cpu/cpu0/cpufreq/ 以下でも見れます.
% cd /sys/devices/system/cpu/cpu0/cpufreq/ % ls affected_cpus cpuinfo_cur_freq cpuinfo_max_freq cpuinfo_min_freq scaling_available_frequencies scaling_available_governors scaling_cur_freq scaling_driver scaling_governor scaling_max_freq scaling_min_freq % cat cpuinfo_cur_freq 1100000 % cat cpuinfo_max_freq 1100000 % cat cpuinfo_min_freq 600000 % cat scaling_governor performance
scaling_governor ってのが動作モードみたいです.変更は sysfs を直接書き変えても
いいですが cpufreq-set コマンドでやるほうが無難ぽいです.
% cpufreq-set -g ondemand % cat scaling_governor ondemand
状態を表示してみます.
% cpufreq-info cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006 Report errors and bugs to linux@brodo.de, please. analyzing CPU 0: driver: centrino CPUs which need to switch frequency at the same time: 0 hardware limits: 600 MHz - 1.10 GHz available frequency steps: 1.10 GHz, 1000 MHz, 900 MHz, 800 MHz, 600 MHz available cpufreq governors: ondemand, performance current policy: frequency should be within 600 MHz and 1.10 GHz. The governor "ondemand" may decide which speed to use within this range. current CPU frequency is 600 MHz (asserted by call to hardware).
クロックが 600MHz に落ちたようですね… CPUに負荷をかけてみてクロックが上がるか試してみます.
% cat cpuinfo_cur_freq 600000 % perl -e 'while(1){}' & [1] 2867 % cat cpuinfo_cur_freq 1100000 % kill %1 % cat cpuinfo_cur_freq 600000 [1]+ Terminated perl -e 'while(1){}'
期待通り動いているっぽいです.あとは起動時にこの状態になるように設定してあげればよさげです.
とりあえず必要なモジュールをロードするように /etc/modules を設定. speedstep-centrino の行をを追加します.
cpufrequtils パッケージには初期化スクリプトとして /etc/init.d/cpufrequtils が入っているので必要な設定を /etc/defaults/cpufrequtils にしてあげれば起動時に自動で設定されるようになります.
とりあえず以下のように設定しました.
% cat /etc/defaults/cpufrequtils ENABLE="true" GOVERNOR="ondemand" MAX_SPEED=0 MIN_SPEED=0
MAX,MIN は 0 にしておけばCPUのサポートしてる最大と最小クロックが設定されるようです.
設定が終ったら再起動して再度テスト.問題なさそうなので終了.