Android 10 系统 CPU 核数、频率、策略控制

一、/sys/devices/system/cpu 目录

Z91:/sys/devices/system/cpu # ls -all
ls -all
total 0
drwxr-xr-x 13 root root    0 2018-01-09 11:17 .
drwxr-xr-x  6 root root    0 2018-01-09 11:17 ..
drwxr-xr-x  5 root root    0 2018-01-09 11:17 cpu0 [查看CPU 核数,频率,策略,频率档位]
drwxr-xr-x  5 root root    0 2018-01-10 14:23 cpu1
drwxr-xr-x  5 root root    0 2018-01-10 14:23 cpu2
drwxr-xr-x  5 root root    0 2018-01-10 14:23 cpu3
drwxr-xr-x  3 root root    0 2018-01-09 11:17 cpufreq
drwxr-xr-x  2 root root    0 2018-01-09 11:17 cpuidle
drwxr-xr-x  2 root root    0 2018-01-09 11:17 cputopo
drwxr-xr-x  2 root root    0 2018-01-09 11:17 eas
-r--r--r--  1 root root 4096 2018-01-09 11:17 isolated
-r--r--r--  1 root root 4096 2018-01-09 11:17 kernel_max
-r--r--r--  1 root root 4096 2018-01-09 11:17 modalias
-r--r--r--  1 root root 4096 2018-01-09 11:17 offline
-r--r--r--  1 root root 4096 2018-01-09 11:17 online [查看 CPU 当前开核]
-r--r--r--  1 root root 4096 2018-01-09 11:17 possible
drwxr-xr-x  2 root root    0 2018-01-09 11:17 power
-r--r--r--  1 root root 4096 2018-01-09 11:17 present [查看 CPU 核数]
drwxr-xr-x  2 root root    0 2018-01-09 11:17 rq-stats
drwxr-xr-x  2 root root    0 2018-01-09 11:17 sched
-rw-r--r--  1 root root 4096 2018-01-09 11:17 uevent

二、查看 CPU 核数、频率、策略
1、查看 CPU 核数
adb shell cat /sys/devices/system/cpu/present

Z91:/sys/devices/system/cpu # cat online
cat online
0-3


2、查看 CPU 当前开核数
adb shell cat /sys/devices/system/cpu/online

Z91:/sys/devices/system/cpu # cat online
cat online
0-3

3、查看 CPU 调频档位
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

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


4、查看 CPU 当前频率
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat cpuinfo_cur_freq
cat cpuinfo_cur_freq
299000


5、查看 CPU 的支持策略
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

D:\AndroidStudioProject\CpuRun>adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
ondemand userspace powersave interactive performance sched


6、查看 CPU 的运行策略
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

D:\AndroidStudioProject\CpuRun>adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
sched

三、设置 CPU 核数、频率、策略
控制 CPU 核数
1、开核命令
adb shell “echo 1 > /sys/devices/system/cpu/cpu【index】/online”

adb shell "echo 1 > /sys/devices/system/cpu/cpu1/online"
adb shell "echo 1 > /sys/devices/system/cpu/cpu2/online"
adb shell "echo 1 > /sys/devices/system/cpu/cpu3/online"


2、关核命令
adb shell “echo 0 > /sys/devices/system/cpu/cpu【index】/online”

adb shell "echo 0 > /sys/devices/system/cpu/cpu1/online"
adb shell "echo 0 > /sys/devices/system/cpu/cpu2/online"
adb shell "echo 0 > /sys/devices/system/cpu/cpu3/online"


3、查询命令
adb shell cat /sys/devices/system/cpu/cpu【index】/online

查看单个
adb shell cat /sys/devices/system/cpu/cpu1/online
adb shell cat /sys/devices/system/cpu/cpu2/online
adb shell cat /sys/devices/system/cpu/cpu3/online

查看全部
adb shell cat /sys/devices/system/cpu/present


控制 CPU 策略
1、需要事先查看所支持策略类型
adb shell “echo 【governor策略】 > /sys/devices/system/cpu/cpu【index】/cpufreq/scaling_governor”

adb shell "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
adb shell "echo ondemand > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor"
adb shell "echo sched > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor"
adb shell "echo interactive > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"

查看修改是否成功
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

控制 CPU 频率
限制最高频率的阈值或者scaling_setspeed,但是实际设置可能觉得没设置到,其实也是正常的,因为CPU调频和场景相关,比如点开应用和滑动桌面都会频率全开,不受到频率控制,这里走了 CPU 场景调频模式了

adb shell “echo 【频率】 > /sys/devices/system/cpu/cpu【index】/cpufreq/scaling_setspeed”

adb shell “echo 【频率】 > /sys/devices/system/cpu/cpu【index】/cpufreq/cpuinfo_max_freq”
 

1.查询支持的档位
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

1274000 1235000 1196000 1170000 1105000 1053000 1001000 962000 910000 845000 702
000 624000 546000 416000 338000 299000

2.查看当前最高频率阈值
adb shell "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
adb shell "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"


3.设置最高当前最高频率阈值 scaling_setspeed
adb shell "echo 845000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
adb shell "echo 845000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
adb shell "echo 1274000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"

4.查看当前频率,验证结果
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq


————————————————
版权声明:本文为CSDN博主「路过独木桥!!」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wq892373445/article/details/126878349

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值