2019年3月6日 星期三

[Linux 學習筆記] 透過 command line 調整 CPU 頻率


1. 查看當前 CPU 0 的使用頻率與最大、最小頻率
# cd /sys/devices/system/cpu/cpu0/cpufreq
# cat cpuinfo_cur_freq
# cat cpuinfo_max_freq
# cat cpuinfo_min_freq


2. 查看 CPU 0 可用頻率
# cd /sys/devices/system/cpu/cpu0/cpufreq
# cat scaling_available_frequencies

==可能顯示結果==
396000 792000 996000


3. 查看 CPU 0 可用的 CPU policy
# cd /sys/devices/system/cpu/cpu0/cpufreq
# cat scaling_available_governors

==可能顯示結果==
interactive conservative ondemand userspace powersave performance



查看所有 CPU 當前 policy
# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

==可能顯示結果==
powersave
powersave
powersave
powersave


4. 更改所有 CPU 當前 mode (假設有 4 顆 CPU)
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
# echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
# echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
此時可查看 current, max, min 頻率來確認是否有更新

5. 手動更改頻率
# echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# echo 792000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq


沒有留言:

張貼留言