1. 切换 CPU 策略为 userspcace
adb shell “echo userspace > /sys/devices/system/cpu/cpu【Index】/cpufreq/scaling_governor”
这里起到固定频率的作用
userspace 最早的 cpufreq 子系统通过 userspace governor 为用户提供了这种灵活性。系统将变频策略的决策权交给了用户态应用程序,并提供了相应的接口供用户态应用程序调节CPU 运行频率使用。(可以使用 Dominik 等人开发了 cpufrequtils 工具包 )
示例
================================================================================
设置前查看当前支持的策略
D:\PythonProject\python3-webapp-Su\www>adb shell cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
sched
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_available_governors
cat scaling_available_governors
ondemand userspace powersave interactive performance sched
================================================================================
设置- userspcace 策略
D:\PythonProject\python3-webapp-Su\www>adb shell "echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
================================================================================
设置后查看
D:\PythonProject\python3-webapp-Su\www>adb shell cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
userspace
2. 设置频率
adb shell “echo [频率档位] > /sys/devices/system/cpu/cpu【Index】/cpufreq/scaling_setspeed”
adb shell “echo 910000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed”
示例
================================================================================
设置前查看频率档次
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_available_frequencies
cat scaling_available_frequencies
1274000 1235000 1196000 1170000 1105000 1053000 1001000 962000 910000 845000 702
000 624000 546000 416000 338000 299000
D:\PythonProject\python3-webapp-Su\www>adb shell "cat /sys/devices/system/cpu/cp
u0/cpufreq/scaling_setspeed"
1274000
================================================================================
设置频率
D:\PythonProject\python3-webapp-Su\www>adb shell "echo 910000 > /sys/devices/sys
tem/cpu/cpu0/cpufreq/scaling_setspeed"
================================================================================
设置后查看
D:\PythonProject\python3-webapp-Su\www>adb shell "cat /sys/devices/system/cpu/cp
u0/cpufreq/scaling_setspeed"
910000
3.验证
查看当前频率
adb shell “cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq”
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_cur_freq
cat scaling_cur_freq
910000
adb shell “cat /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table”
Z91:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
cat trans_table
From : To
: 1274000 1235000 1196000 1170000 1105000 1053000 1001000
962000 910000 845000 702000 624000 546000 416000 338000
299000
1274000: 0 72086 30152 45166 26802 22756 12876
14665 15069 19964 9916 7919 9179 5340 2574
40418
1235000: 157400 0 5901 4770 2327 2112 2596
2698 2500 3182 1094 688 505 364 127
3543
1196000: 34936 67770 0 6519 1791 1316 955
1945 1560 2324 899 526 380 201 86
1778
1170000: 40951 26632 67810 0 7262 3694 2242
4277 5075 6946 2082 1148 936 583 204
3856
1105000: 16596 8787 9777 75941 0 5691 2241
2475 5080 7311 2249 1169 856 480 201
3011
1053000: 12324 2572 3135 22246 71408 0 5509
4314 3505 11277 3786 1989 1446 625 266
2640
1001000: 7200 1604 908 5496 14872 67595 0
5141 3611 7775 4061 2273 1492 512 198
2607
962000: 8339 1831 1061 3513 7956 25683 68943
0 7431 14108 9196 5912 4174 1179 490
3578
910000: 7886 1503 956 2602 3442 9306 16914
78332 0 15817 8116 6036 4673 1071 414
4904
845000: 12534 1354 928 2215 2172 5106 9893
44259 102265 0 20634 27991 44054 11631 2671
19834
702000: 8385 698 453 929 602 789 1002
2361 10980 129393 0 12538 37133 17373 4490
22439
624000: 5710 464 254 695 772 971 776
874 1531 34078 93861 0 20684 19690 5655
35303
546000: 5514 361 205 439 378 380 248
420 763 46006 66027 30107 0 22667 9997
41643
416000: 3629 494 379 1233 1080 735 407
536 827 3219 22281 113398 28840 0 12555
131669
338000: 610 119 50 86 47 65 49
63 136 521 582 3063 34551 11133 0
16250
299000: 12868 3532 1017 1848 954 843 694
1033 1640 5620 4781 6561 36252 228433 27397
0
Z91:/sys/devices/system/cpu/cpu0/cpufreq/stats #