cpufreqによるクロック周波数制御
2010/12/27
cpufreqによるクロック周波数制御(Debian Lenny)
cpufreqはLinuxのCPUクロック周波数制御をする際に利用できるツール.Debian Lennyでは普通に使えるらしい.
まずはcpufreq-infoコマンドで様子を見てみる.
ushi@BigOwl:~$cpufreq-info cpufrequtils 004: cpufreq-info (C) Dominik Brodowski 2004-2006 Report errors and bugs to cpufreq@lists.linux.org.uk, please. analyzing CPU 0: driver: acpi-cpufreq CPUs which need to switch frequency at the same time: 0 1 2 3 hardware limits: 2.00 GHz - 2.66 GHz available frequency steps: 2.66 GHz, 2.00 GHz available cpufreq governors: ondemand, conservative, userspace, powersave, performance current policy: frequency should be within 2.00 GHz and 2.66 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 2.66 GHz. cpufreq stats: 2.66 GHz:28.78%, 2.00 GHz:71.22% (2023996) analyzing CPU 1: driver: acpi-cpufreq CPUs which need to switch frequency at the same time: 0 1 2 3 hardware limits: 2.00 GHz - 2.66 GHz available frequency steps: 2.66 GHz, 2.00 GHz available cpufreq governors: ondemand, conservative, userspace, powersave, performance current policy: frequency should be within 2.00 GHz and 2.66 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 2.66 GHz. cpufreq stats: 2.66 GHz:28.78%, 2.00 GHz:71.22% (2023996) analyzing CPU 2: driver: acpi-cpufreq CPUs which need to switch frequency at the same time: 0 1 2 3 hardware limits: 2.00 GHz - 2.66 GHz available frequency steps: 2.66 GHz, 2.00 GHz available cpufreq governors: ondemand, conservative, userspace, powersave, performance current policy: frequency should be within 2.00 GHz and 2.66 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 2.66 GHz. cpufreq stats: 2.66 GHz:28.78%, 2.00 GHz:71.22% (2023996) analyzing CPU 3: driver: acpi-cpufreq CPUs which need to switch frequency at the same time: 0 1 2 3 hardware limits: 2.00 GHz - 2.66 GHz available frequency steps: 2.66 GHz, 2.00 GHz available cpufreq governors: ondemand, conservative, userspace, powersave, performance current policy: frequency should be within 2.00 GHz and 2.66 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 2.66 GHz. cpufreq stats: 2.66 GHz:28.78%, 2.00 GHz:71.22% (2023996) ushi@BigOwl:~$各コアについての情報が表示される.表示されるのは,
- ハードウェアの対応するクロック周波数の範囲(hardware limits),
- 現在利用可能なクロック周波数の段階(available frequency steps),
- 利用可能なcpufreq governorsのモード(available cpufreq governors),
- 現在の制御方針(current policy),
- 現在のクロック周波数(current CPU frequency is ○○),
- cpufreqの状態(各クロック周波数でどのくらいの時間動作しているか%表示?)(cpufreq stats)
簡単にクロック制御するにはcpufreq-setの-gオプションというのを使う.
gはcpufreq governorsのg.available cpufreq governorsの行を見ると,『ondemand, conservative, userspace, powersave, performance』という記述がある.
ondemandは負荷に応じてクロック制御をしてくれるモード,conservativeは前者よりも制御の負荷に対する応答が緩やかなモード,
userspaceはユーザの任意指定モード(といっても今は何も設定していないので,どうなる?),
powersaveは常に最低クロック周波数で動作,performanceは常に最大クロック周波数で動作というモード.
今回は動画エンコードを少しでも早く終わらせるという目的があるため,performanceに設定することにしよう.
BigOwl:/home/ushi# cpufreq-set -g performance BigOwl:/home/ushi#ハードウェアに関連する操作なので,管理者権限は必須である.
なので,rootにスイッチして実行する.一般ユーザで実行しようとするとエラーになる.
ushi@BigOwl:~$ cpufreq-set -g performance Error setting new values. Common errors: - Do you have proper administration rights? (super-user?) - Is the governor you requested available and modprobed? - Trying to set an invalid policy? - Trying to set a specific frequency, but userspace governor is not available, for example because of hardware which cannot be set to a specific frequency or because the userspace governor isn't loaded?
とりあえず,これでクロック周波数をある程度任意に設定できるようになった.
もっときめの細かい制御もすることも可能であるらしい.こちらサイトの方の記述によれば.
ただ,findでざっと該当しそうなファイルを探してみたのだが,見つからない.
自分で設定ファイルを書くんだろうか.暇なときにやってみようか…….