一、 /sys/devices/system/cpu/cpu0 目录结构
/sys/devices/system/cpu/cpu0
Z91:/sys/devices/system/cpu/cpu0 # ls -al
ls -al
total
drwxr-xr-x root root --09 : .
drwxr-xr-x root root --09 : ..
lrwxrwxrwx root root --09 : cpufreq -> ../cpufreq/policy
drwxr-xr-x root root --09 : cpuidle
lrwxrwxrwx root root --09 : of_node -> ../../../../firmware/de
vicetree/base/cpus/cpu@0
-rw-r--r-- root root --09 : online
drwxr-xr-x root root --09 : power
lrwxrwxrwx root root --09 : subsystem -> ../../../../bus/cpu
drwxr-xr-x root root --09 : topology
-rw-r--r-- root root --09 : uevent
二、重要信息获取
1. CPU 频率
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
cat cpuinfo_cur_freq
2.CPU 所支持的主频率列表(KHZ)
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
CPU 调频需要选择对应的档位,且参数不同机器该配置不同
3.CPU 策略policy
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_available_governors
cat scaling_available_governors
ondemand userspace powersave interactive performance sched
- ondemand 表示使用内核提供的功能,可以动态调节频率
- userspace 表示用户模式,在此模式下允许其他用户程序调节CPU频率
- powersvae 表示省电模式,通常是在最低频率下运行
- interactive ondemand相似,规则是“快升慢降”
- performance 表示不降频,最高性能
- sched 基于调度器的 CPU 调频机制
4.查看当前 CPU 的运行模式
通过echo命令,能够改变当前处理器的governor类型
Z91:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_governor
cat scaling_governor
sched
三、 目录详情
1. cpufreq
主要获取 CPU 的频率、调频档位及策略等
http://blog.csdn.net/su749520/article/details/79023509
2. cpuidle
Z91:/sys/devices/system/cpu/cpu0/cpuidle # ls -al
ls -al
total
drwxr-xr-x root root --09 : .
drwxr-xr-x root root --09 : ..
drwxr-xr-x root root --09 : driver
drwxr-xr-x root root --09 : state
drwxr-xr-x root root --09 : state1
2.1 cpuidle/driver
Z91:/sys/devices/system/cpu/cpu0/cpuidle/driver # ls -al
ls -al
total
drwxr-xr-x root root --09 : .
drwxr-xr-x root root --09 : ..
-r--r--r-- root root --09 : name
2.1.1 cpuidle/driver/name
Z91:/sys/devices/system/cpu/cpu0/cpuidle/driver # cat name
cat name
mt67xx_acao_cpuidle
2.2 cpuidle/state0
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # ls -al
ls -al
total 0
drwxr-xr-x 2 root root 0 2018-01-09 11:17 .
drwxr-xr-x 5 root root 0 2018-01-09 11:17 ..
-r--r--r-- 1 root root 4096 2018-01-09 11:17 desc
-rw-r--r-- 1 root root 4096 2018-01-09 11:17 disable
-r--r--r-- 1 root root 4096 2018-01-09 11:17 latency
-r--r--r-- 1 root root 4096 2018-01-09 11:17 name
-r--r--r-- 1 root root 4096 2018-01-09 11:17 power
-r--r--r-- 1 root root 4096 2018-01-09 11:17 residency
-r--r--r-- 1 root root 4096 2018-01-09 11:17 time
-r--r--r-- 1 root root 4096 2018-01-09 11:17 usage
2.2.2 cpuidle/state0/desc
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # cat desc
cat desc
wfi
2.2.2 cpuidle/state0/disable
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # cat disable
cat disable
2.2.2 cpuidle/state0/latency
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # cat latency
cat latency
2.2.2 cpuidle/state0/name
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # cat name
cat name
rgidle
2.2.2 cpuidle/state0/power
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # cat power
cat power
2.2.2 cpuidle/state0/residency
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # cat residency
cat residency
2.2.2 cpuidle/state0/usage
Z91:/sys/devices/system/cpu/cpu0/cpuidle/state0 # cat usage
cat usage
2.3 cpuidle/state1
目录结构和 state0 一致
3. of_node
Z91:/sys/devices/system/cpu/cpu0/of_node # ls -al
ls -al
total 0
drwxr-xr-x 2 root root 0 2018-01-10 14:56 .
drwxr-xr-x 8 root root 0 2018-01-10 14:56 ..
-r--r--r-- 1 root root 4 2018-01-10 14:56 clock-frequency
-r--r--r-- 1 root root 15 2018-01-10 14:56 compatible
-r--r--r-- 1 root root 28 2018-01-10 14:56 cpu-idle-states
-r--r--r-- 1 root root 8 2018-01-10 14:56 cpu-release-addr
-r--r--r-- 1 root root 4 2018-01-10 14:56 device_type
-r--r--r-- 1 root root 5 2018-01-10 14:56 enable-method
-r--r--r-- 1 root root 4 2018-01-10 14:56 linux,phandle
-r--r--r-- 1 root root 4 2018-01-10 14:56 name
-r--r--r-- 1 root root 4 2018-01-10 14:56 phandle
-r--r--r-- 1 root root 4 2018-01-10 14:56 reg
3.1 /of_node/clock-frequency
|Z91:/sys/devices/system/cpu/cpu0/of_node # cat clock-frequency
cat clock-frequency
w5?
3.2 /of_node/compatible
获取CPU架构信息
w5?Z91:/sys/devices/system/cpu/cpu0/of_node # cat compatible
cat compatible
arm,cortex-a53
3.3 /of_node/cpu-idle-states
cat 不出
3.4 /of_node/cpu-release-addr
cat 不出
3.5 /of_node/device_type
Z91:/sys/devices/system/cpu/cpu0/of_node # cat device_type
cat device_type
cpu
3.6 /of_node/enable-method
psci
3.7 /of_node/linux,phandle
cat 不出
3.8 /of_node/name
cpu
3.9 /of_node/phandle
cat 不出
3.10 /of_node/reg
cat 不出
4. online
查询结果如下
Z91:/sys/devices/system/cpu/cpu0 # cat online
cat online
表示当前 CPU 正在使用
5. power
Z91:/sys/devices/system/cpu/cpu0/power # ls -all
ls -all
total 0
drwxr-xr-x 2 root root 0 2018-01-09 11:17 .
drwxr-xr-x 5 root root 0 2018-01-09 11:17 ..
-rw-r--r-- 1 root root 4096 2018-01-09 11:17 autosuspend_delay_ms
-rw-r--r-- 1 root root 4096 2018-01-09 11:17 control
-r--r--r-- 1 root root 4096 2018-01-09 11:17 runtime_active_time
-r--r--r-- 1 root root 4096 2018-01-09 11:17 runtime_status
-r--r--r-- 1 root root 4096 2018-01-09 11:17 runtime_suspended_time
5.1 /power/autosuspend_delay_ms
cat 不出
Z91:/sys/devices/system/cpu/cpu0/power # cat autosuspend_delay_ms
cat autosuspend_delay_ms
/system/bin/sh: cat: autosuspend_delay_ms: I/O error
5.2 /power/control
cat control
auto
5.3 /power/runtime_active_time
cat runtime_active_time
5.4 /power/runtime_status
cat runtime_status
unsupported
5.5 /power/runtime_suspended_time
cat runtime_suspended_time
6. subsystem
Z91:/sys/devices/system/cpu/cpu0/subsystem # ls -all
ls -all
total
drwxr-xr-x root root -- : .
drwxr-xr-x root root --09 : ..
drwxr-xr-x root root -- : devices
drwxr-xr-x root root -- : drivers
-rw-r--r-- root root -- : drivers_autoprobe
--w------- root root -- : drivers_probe
--w------- root root -- : uevent
6.1 /subsystem/devices
Z91:/sys/devices/system/cpu/cpu0/subsystem/devices # ls -all
ls -all
total
drwxr-xr-x root root -- : .
drwxr-xr-x root root -- : ..
lrwxrwxrwx root root -- : cpu -> ../../../devices/system/cpu/cp
u
lrwxrwxrwx root root -- : cpu1 -> ../../../devices/system/cpu/cp
u1
lrwxrwxrwx root root -- : cpu2 -> ../../../devices/system/cpu/cp
u2
lrwxrwxrwx root root -- : cpu3 -> ../../../devices/system/cpu/cp
u3
6.2 /subsystem/drivers
空文件夹
6.3 /subsystem/drivers_autoprobe
Z91:/sys/devices/system/cpu/cpu0/subsystem # cat drivers_autoprobe
cat drivers_autoprobe
6.4 /subsystem/drivers_probe
Z91:/sys/devices/system/cpu/cpu0/subsystem # cat drivers_probe
cat drivers_probe
/system/bin/sh: cat: drivers_probe: Permission denied
6.5 /subsystem/uevent
|Z91:/sys/devices/system/cpu/cpu0/subsystem # cat uevent
cat uevent
/system/bin/sh: cat: uevent: Permission denied
7. topology
Z91:/sys/devices/system/cpu/cpu0/topology # ls -all
ls -all
total 0
drwxr-xr-x 2 root root 0 2018-01-09 11:17 .
drwxr-xr-x 5 root root 0 2018-01-09 11:17 ..
-r--r--r-- 1 root root 4096 2018-01-09 11:17 core_id
-r--r--r-- 1 root root 4096 2018-01-09 11:17 core_siblings
-r--r--r-- 1 root root 4096 2018-01-09 11:17 core_siblings_list
-r--r--r-- 1 root root 4096 2018-01-09 11:17 physical_package_id
-r--r--r-- 1 root root 4096 2018-01-09 11:17 thread_siblings
-r--r--r-- 1 root root 4096 2018-01-09 11:17 thread_siblings_list
7.1 topology/core_id
cat core_id
7.2 topology/core_siblings
cat core_siblings
f
7.3 topology/core_siblings_list
cat core_siblings_list
-
7.4 topology/physical_package_id
cat physical_package_id
7.5 topology/thread_siblings
cat thread_siblings
7.6 topology/thread_siblings_list
cat thread_siblings_list
8. uevent
查询结果如下
Z91:/sys/devices/system/cpu/cpu0 # cat uevent
cat uevent
OF_NAME=cpu
OF_FULLNAME=/cpus/cpu@0
OF_TYPE=cpu
OF_COMPATIBLE_0=arm,cortex-a53
OF_COMPATIBLE_N=
MODALIAS=cpu:type:aarch64:feature:,,,,,,,,