まず現在の動作速度および動作モード(ガバナーというらしい)を cpufreq-info コマンドで確認する。
debian@beaglebone:~$ cpufreq-info cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: cpufreq-dt CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 300 us. hardware limits: 300 MHz - 1000 MHz available frequency steps: 300 MHz, 600 MHz, 720 MHz, 800 MHz, 1000 MHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 300 MHz and 1000 MHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 1000 MHz. cpufreq stats: 300 MHz:0.00%, 600 MHz:0.00%, 720 MHz:0.00%, 800 MHz:0.00%, 1000 MHz:100.00%
PocketBeagle は 300MHz, 600Mz, 720MHz, 800MHz, 1000MHz で動作可能。 (デフォルトは 1000MHz)
The governor "performance"...
とあるので、現在 performance ガバナーで動作している事がわかる。
PocketBeagle でサポートしているガバナーはconservative, ondemand, userspace, powersave, performance
の5つ。
debian@beaglebone:~$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors conservative ondemand userspace powersave performance
Archlinux の スケーリング governor のページと比較すると、PocketBeagle ではschedutil 以外のガバナーを全てサポートしている。
Exploring BeagleBone: Tools and Techniques for Building with Embedded Linux では、ondemand ガバナーでCPU負荷にしきい値を設定して、しきい値を超えたタイミングでCPUの動作速度を変更する例が記載されていたが、自分の用途では遠隔から手動で動作を切り替える、という手段が望ましい。
試しに動作速度を最低の 300MHz まで落としてみる。
debian@beaglebone:~$ sudo cpufreq-set -f 300MHz debian@beaglebone:~$ cpufreq-info cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: cpufreq-dt CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 300 us. hardware limits: 300 MHz - 1000 MHz available frequency steps: 300 MHz, 600 MHz, 720 MHz, 800 MHz, 1000 MHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 300 MHz and 1000 MHz. The governor "userspace" may decide which speed to use within this range. current CPU frequency is 300 MHz. cpufreq stats: 300 MHz:2.43%, 600 MHz:9.19%, 720 MHz:0.00%, 800 MHz:0.00%, 1000 MHz:88.38% (26)
簡単に動作速度を変更できた。
組み込み用途でスタンバイ中に消費電力を抑えるのに使えそうだ。
なお、起動時にデフォルトで選択されるガバナーはperformance。
これを変更したい場合は、起動スクリプトを直接編集するしかないようだ。
debian@beaglebone:~$ sudo grep -B20 -A2 -e "^GOVERNOR=" /etc/init.d/cpufrequtils # Which governor to use. Must be one of the governors listed in: # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors # # and which limits to set. Both MIN_SPEED and MAX_SPEED must be values # listed in: # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies # a value of 0 for any of the two variables will disabling the use of # that limit variable. # # WARNING: the correct kernel module must already be loaded or compiled in. # # Set ENABLE to "true" to let the script run at boot time. # # eg: ENABLE="true" # GOVERNOR="performance" # MAX_SPEED=1000 # MIN_SPEED=500 ENABLE="true" GOVERNOR="performance" MAX_SPEED="0" MIN_SPEED="0"
ガバナーの考え方は、Redhat のドキュメントが分かりやすかった。
※ もし cpufreq-info コマンドがインストールされていない場合は apt install で取ってくる。 (自分の環境では既にインストールされていた)
debian@beaglebone:~$ sudo apt install cpufrequtils [sudo] password for debian: Reading package lists... Done Building dependency tree Reading state information... Done cpufrequtils is already the newest version (008-1+b1). 0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.