Android system fixed CPU frequency

1. Switch CPU policy to userspcache

adb shell "echo userspace > /sys/devices/system/cpu/cpu[Index]/cpufreq/scaling_governor"

It's a fixed frequency

The first cpufreq subsystem of userspace provides users with this flexibility through userspace governor. The system gives the decision-making power of the frequency conversion strategy to the user application program, and provides the corresponding interface for the user application program to adjust the CPU operation frequency. (you can use Dominik and others to develop the cpufrequtils Toolkit)

Example
================================================================================
//View currently supported policies before setting
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

================================================================================
//Settings - userspcache policy
D:\PythonProject\python3-webapp-Su\www>adb shell "echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

================================================================================
//View after setting
D:\PythonProject\python3-webapp-Su\www>adb shell cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
userspace

2. Set frequency

adb shell "echo [frequency gear] > / sys / devices / system / CPU / CPU [Index] / cpufreq/scaling_setspeed"

adb shell "echo 910000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

Example
================================================================================
//View frequency level before setting
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
================================================================================
//Set frequency
D:\PythonProject\python3-webapp-Su\www>adb shell "echo 910000 > /sys/devices/sys
tem/cpu/cpu0/cpufreq/scaling_setspeed"

================================================================================
//View after setting
D:\PythonProject\python3-webapp-Su\www>adb shell "cat /sys/devices/system/cpu/cp
u0/cpufreq/scaling_setspeed"
910000

3. Verification

View current frequency

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 #

Tags: shell

Posted on Thu, 30 Apr 2020 03:46:41 -0700 by skissiks