高通、MTK、紫光展锐CPU超大核、大核、小核分布查询及绑定方法

高通,MTK,紫光展锐 CPU大核中核小核查询 以及绑定

  • 概述
  • 查看手机cpu 的大小核分布情况
  • 1,如果知道CUP 型号直接去官网查找, 例如Kirin9000 。
  • 2,有手机,也可去通过adb shell 来查看
  • 使用taskset 命令来查看进程所运行的CPU
  • 通过进程号cat cpuset,cpus 命令来查看进程所运行的CPU
  • 使用top -H -O CPU -p <进程号> 查看进程关联进程
  • 绑定大核
  • 概述

    超大核在制成,主频,V9指令集,都有大幅提升,因此运行 起来更快。因此绑定大核或者超级大核对某个模块的进程运行会起到非常明显提速。像追求极速的某些模块来说具有非常重要的作用, 比如说触控的高刷,显示屏的高刷, 指纹模块的疾速解锁,faceID等都会用到。

    目前主流手机基本都是8核处理器, 这个8个处理器中,不是每个都一样的,结合实用与经济性,IC设计时会使用不同制程工艺。8 个处理器可以有不同的分配。例如近期最流行的架构位1+3+4, 即1个超大核+3个大核+4个小核。 如下时列举不同厂家部分处理器型号的分布。

    查看手机cpu 的大小核分布情况

    1,如果知道CUP 型号直接去官网查找, 例如Kirin9000 。

    添加链接描述

    https://www.hisilicon.com/cn/products/Kirin/Kirin-flagship-chips/Kirin-9000

    2,有手机,也可去通过adb shell 来查看

    使用 ls /sys/devices/system/cpu/cpufreq 命令 看有几个policy 类就分为几种CPU, 如上图MT6789分为2组。

    ls /sys/devices/system/cpu/cpufreq
    
    C:\platform-tools>adb shell
    k6789v1_64:/ $ ls  /sys/devices/system/cpu/cpufreq
    policy0  policy6
    

    SM8450 有3个policy 因此有三种类型的CPU,

    AI2202:/ $ ls  /sys/devices/system/cpu/cpufreq
    policy0  policy4  policy7
    

    如上图SM8450分为两3组。

    通过related_cpus去查看每一组所关联的cpu。可以看到SM8450分组情况如下:

     AI2202:/ $ cat /sys/devices/system/cpu/cpufreq/policy0/related_cpus
    0 1 2 3
     AI2202:/ $ cat /sys/devices/system/cpu/cpufreq/policy4/related_cpus
    4 5 6
     AI2202:/ $ cat /sys/devices/system/cpu/cpufreq/policy7/related_cpus
    7
    

    通过cpuinfo_max_freq去查看每一组cpu最大主频,从而来确定哪一个时大核或者超大核。可以看到SM8450超大核为policy7 的cpu7 ,最大支持3GHz

     AI2202:/ $ cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq
    1785600
     AI2202:/ $ cat /sys/devices/system/cpu/cpufreq/policy4/cpuinfo_max_freq
    2496000
     AI2202:/ $ cat /sys/devices/system/cpu/cpufreq/policy7/cpuinfo_max_freq
    2995200
    

    通过cpuinfo_cur_freq去查看每一组cpu当前工作频率,这部分后续提频会确认到改参数。

     AI2202:/ # cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq
    1478400
     AI2202:/ # cat /sys/devices/system/cpu/cpufreq/policy4/cpuinfo_cur_freq
    1881600
     AI2202:/ # cat /sys/devices/system/cpu/cpufreq/policy7/cpuinfo_cur_freq
    2054400
    

    通过related_cpus去查看每一组所关联的cpu。可以看到MT6789分组情况如下:

    k6789v1_64:/ # cat /sys/devices/system/cpu/cpufreq/policy0/related_cpus
    0 1 2 3 4 5
    k6789v1_64:/ # cat /sys/devices/system/cpu/cpufreq/policy6/related_cpus
    6 7
    

    通过cpuinfo_max_freq去查看每一组cpu最大主频,从而来确定哪一个时大核或者超大核。可以看到MT6789超大核为policy6 里面的 cpu6, cpu7两个cpu,最大支持2.2GHz

    k6789v1_64:/ # cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq
    2000000
    k6789v1_64:/ # cat /sys/devices/system/cpu/cpufreq/policy6/cpuinfo_max_freq
    2200000
    

    通过cpuinfo_cur_freq去查看每一组cpu当前工作频率,这部分后续提频会确认到改参数。

    k6789v1_64:/ # cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq
    500000
    k6789v1_64:/ # cat /sys/devices/system/cpu/cpufreq/policy6/cpuinfo_cur_freq
    1200000
    

    使用taskset 命令来查看进程所运行的CPU

    OS当中所运行的进程不是每个CPU 都能跑的, 会收到CPU调度规则的约束,考虑到功耗,时效,以及资源问题,cpu会有一套合理的调度规范, 对一下时速优先权要求不要的进程一般都会放在小核里面。

    以指纹为例,使用ps -A| grep fingerprint 来查找指纹进程号。

    k6789v1_64:/ # ps   -A| grep   fingerprint
    system        1286     1 10920640  7164 binder_wait_for_work 0 S android.hardware.biometrics.fingerprint@2.1-service
    

    通过taskset -p pid(进程号)来看改进程会有那些cpu 来调度。 如果mask是ff,ff转化成二进制是 0x11111111 ,每个1位代表一个cpu,8位为1,则8个cpu 都可以来调度,对应的顺序为从左到右,高位到低位, 对应cpu7到cpu0,但是什么时候用不确定。

    k6789v1_64:/ # taskset  -p   1286
    pid 1286's current affinity mask: ff
    

    如果mask出来时只有一位数如下所示,可能时在init 脚本中限制只能在规定的四个核中调度运行。 需要修改脚本。具体请见下一篇文章。

    k6789v1_64:/ # taskset  -p   1286
    pid 1286's current affinity mask: f
    

    2,通过taskset -p xx(十六进制) pid(进程号)来看改进程会有那些cpu 来调度。 设置成3f(0x00111111), 因此只有cpu5~cpu0可以调度,属于小核,

    k6789v1_64:/ # taskset  -p  3f  1286
    pid 1286's current affinity mask: ff
    pid 1286's new affinity mask: 3f
    k6789v1_64:/ # taskset  -p   1286
    pid 1286's current affinity mask: 3f
    
    

    bit7–第4个核(cpu7)
    bit6–第3个核(cpu6)
    bit5–第2个核(cpu5)
    bit4–第1个核(cpu4)
    bit3–第4个核(cpu3)
    bit2–第3个核(cpu2)
    bit1–第2个核(cpu1)
    bit0–第1个核(cpu0)

    通过进程号cat cpuset,cpus 命令来查看进程所运行的CPU

    //ps 进程号
    k6789v1_64:/ # ps  -A|grep   finger
    system        1286     1 10889920  7120 binder_wait_for_work 0 S android.hardware.biometrics.fingerprint@2.1-service
    
    //cat  proc/1286/cpuset  查找进程号分组
    k6789v1_64:/ # cat  proc/1286/cpuset
    /system-backgroun
    
    //cat 分组关联的cpus
    k6789v1_64:/ # cat dev/cpuset/system-background/cpus
    0-3
    

    使用top -H -O CPU -p <进程号> 查看进程关联进程

    用top -H -O CPU -p 1286 看一下1286进程关联进行的所用的cpu, [CPU] 一列关联进程都在cpu0~cpu3之间。
    ![CPU调度](https://i3.wp.com/img-blog.csdnimg.cn/bf5416ff8bac4501af10c5f504137c5c.png

    cpu0~cpu3小核下,指纹模块录入指纹的时间大致950ms左右,时间比较长。

    C:\Users\11599>adb shell
    k6789v1_64:/ # logcat |grep   "total time"
    03-28 15:12:28.055  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=1166ms
    03-28 15:13:18.512  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=847ms
    03-28 15:13:23.822  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=872ms
    03-28 15:13:25.393  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=918ms
    03-28 15:13:27.573  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=908ms
    03-28 15:13:29.485  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=893ms
    03-28 15:13:33.046  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=943ms
    03-28 15:13:35.294  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=964ms
    03-28 15:13:37.731  1286  1654 I [FingerprintCore]: [notifyEnrollProgress]    total time=998ms
    
    

    绑定大核

    因为MT6789只有cpu6 cpu7是大核, 因此绑定大核mask 为1100 0000 (0xc0) ,因此使用taskset -p c0 1286来绑定大核。

    k6789v1_64:/ # ps -A|grep   finger
    system        1284     1 10953408  7176 binder_wait_for_work 0 S android.hardware.biometrics.fingerprint@2.1-service
    k6789v1_64:/ # taskset  -p   c0 1286
    pid 1284's current affinity mask: ff
    pid 1284's new affinity mask: c0
    

    taskset 查到已经绑定到大核。

    k6789v1_64:/ # taskset  -p    1286
    pid 1284's current affinity mask: c0
    

    top查看关联进程,大部分进程都已经在大核中运行。
    绑大核

    指纹模块录入指纹的时间大致450ms左右,时间比之前快了一半,这就是大核的效果立竿见影。

    C:\Users\11599>adb shell
    k6789v1_64:/ #  logcat |grep   "total time"
    03-28 15:49:03.482  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=587ms
    03-28 15:49:06.804  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=420ms
    03-28 15:49:08.114  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=428ms
    03-28 15:49:09.144  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=436ms
    03-28 15:49:11.004  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=447ms
    03-28 15:49:13.001  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=450ms
    03-28 15:49:13.946  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=444ms
    03-28 15:49:16.596  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=424ms
    03-28 15:49:17.703  1284  1534 I [FingerprintCore]: [notifyEnrollProgress]    total time=470ms
    
    物联沃分享整理
    物联沃-IOTWORD物联网 » 高通、MTK、紫光展锐CPU超大核、大核、小核分布查询及绑定方法

    发表回复