平台硬件信息

CPU

Android cpu affinity

android:/ # taskset --help
usage: taskset [-ap] [mask] [PID | cmd [args...]]

Launch a new task which may only run on certain processors, or change the processor affinity of an existing PID.

Mask is a hex string where each bit represents a processor the process is allowed to run on. PID without a mask displays existing affinity.

-p      Set/get the affinity of given PID instead of a new command
-a      Set/get the affinity of all threads of the PID

cpuinfo

X86

# 查看物理CPU个数
cat /proc/cpuinfo|grep "physical id"|sort -u|wc -l

# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo|grep "cpu cores"|uniq

# 查看逻辑CPU的个数
cat /proc/cpuinfo|grep "processor"|wc -l

# 查看CPU的名称型号
cat /proc/cpuinfo|grep "name"|cut -f2 -d:|uniq

arm

# 查看逻辑CPU的个数
cat /proc/cpuinfo|grep "processor"|wc -l

# 查看CPU的名称型号
cat /proc/cpuinfo | grep -i hardware

QCOM powerhint 实现

通过设置 msm_performance 的参数实现

  • /sys/module/msm_performance/parameters/cpu_max_freq
  • /sys/module/msm_performance/parameters/cpu_min_freq

到底几个 cluster

ls /sys/devices/system/cpu/cpufreq
policy0 policy6

/sys/devices/system/cpu/cpufreq 文件夹下几个 policyn 文件夹,就代表有几个 cluster

cluster 下的 CPU

cat /sys/devices/system/cpu/cpufreq/policy6/affected_cpus
6 7

CPU 频率

最大频率

cat /sys/devices/system/cpu/cpufreq/policy6/cpuinfo_max_freq

最小频率

cat /sys/devices/system/cpu/cpufreq/policy6/cpuinfo_min_freq

所有可用的频率

cat /sys/devices/system/cpu/cpufreq/policy6/scaling_available_frequencies

软件限制的最大最小频率

cat /sys/devices/system/cpu/cpufreq/policy6/cat scaling_min_freq
cat /sys/devices/system/cpu/cpufreq/policy6/scaling_min_freq

查看当前频率

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

cpuinfo 是参数表,So what about cpuinfo_cur_freq?

This parameter has more to do with the specification of the CPU and which profile it’s currently in, rather than anything useful with respect to how the CPU is currently operating. For actual operational telemetry I’d use the scaling_* kernel tunables.

关闭开启 CPUx

查看 CPUx 是否打开

cat /sys/devices/system/cpu/cpu0/online
  • 0 表示该核心是offline状态的,关闭状态,
  • 1 表示该核心是online状态的,开启状态。

设置 CPUx 是否打开

echo "0" >/sys/devices/system/cpu/cpu0/online # 关闭该CPU
echo "1" > /sys/devices/system/cpu/cpu0/online# 打开该CPU
  1. 如何修改CPU运行个数

    高通平台上每一个cluster第一个CPU上会有一个特殊的core_ctl目录用来控制当前cluster上的运行CPU个数。以高通SM6125平台为例,可以获知有2个cluster,小核为0~3一共4个CPU,大核为4~7一共4个CPU。

    在CPU0相应的core_ctl目录下我们看到如下的配置参数:

    android:/sys/devices/system/cpu/cpu0/core_ctl # ls
    active_cpus     busy_up_thres global_state min_cpus  not_preferred         offline_delay_ms
    busy_down_thres enable        max_cpus     need_cpus nr_prev_assist_thresh task_thres
    

    其中min_cpus跟max_cpus用来控制cluster上所运行的CPU个数。Core_ctl会根据当前系统的负载及运行任务数来动态的调节运行CPU的个数。

    android:/sys/devices/system/cpu/cpu0/core_ctl # cat max_cpus
    4
    android:/sys/devices/system/cpu/cpu0/core_ctl # cat min_cpus
    4
    

设置CPU工作模式

CPU 支持多种工作模式 governor,模式主要对cpu工作频率进行修改。查询CPU支持的模式:

adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

列举常见的几种工作模式:

interactive ondemand userspacepowersave performance
  • performance性能最好,CPU 核心会一直保持在可用的最高频率,
  • ondemand 表示使用内核提供的功能,可以动态调节频率,
  • powersvae表示省电模式,是在最低频率下运行,
  • userspace表示用户模式,在此模式下允许其他用户程序调节CPU频率。

设置工作模式:

echo "performance" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

C-states

The basic C-states (defined by ACPI) are:

  • C0: Active, CPU/Core is executing instructions. P-states are relevant here, CPU/Core may be operating at its maximum performance (thus at P0) or at a lower performance/power (thus at anything other than P0).
  • C1: Halt, nothing is being executed, but it can return to C0 instantenously. Since it is not working (but halted), P-states are not relevant for C1 or any Cx other than C0.
  • C2: Stop-Clock, similar to C1 but it takes longer time to go back to C0.
  • C3: Sleep. It can go back to C0, but it will take considerably longer time.

获取 CPU 频率示例

#!/system/bin/sh

i=0
while :
do

  i=$((i+1))
  if [ $i -gt 12 ]; then
    break
  fi

echo 'silver scaling_available_frequencies:'
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
echo 'gold scaling_available_frequencie:'
cat /sys/devices/system/cpu/cpufreq/policy4/scaling_available_frequencies

printf "\n\n"

silver_max_freq=`cat /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq`
silver_min_freq=`cat /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq`
gold_max_freq=`cat /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq`
gold_min_freq=`cat /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq`

online_cpu0=`cat /sys/devices/system/cpu/cpu0/online`
online_cpu1=`cat /sys/devices/system/cpu/cpu1/online`
online_cpu2=`cat /sys/devices/system/cpu/cpu2/online`
online_cpu3=`cat /sys/devices/system/cpu/cpu3/online`
online_cpu4=`cat /sys/devices/system/cpu/cpu4/online`
online_cpu5=`cat /sys/devices/system/cpu/cpu5/online`
online_cpu6=`cat /sys/devices/system/cpu/cpu6/online`
online_cpu7=`cat /sys/devices/system/cpu/cpu7/online`

cur_freq0=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`
cur_freq1=`cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq`
cur_freq2=`cat /sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq`
cur_freq3=`cat /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq`
cur_freq4=`cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq`
cur_freq5=`cat /sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq`
cur_freq6=`cat /sys/devices/system/cpu/cpu6/cpufreq/scaling_cur_freq`
cur_freq7=`cat /sys/devices/system/cpu/cpu7/cpufreq/scaling_cur_freq`

gpubusy=`cat /sys/class/kgsl/kgsl-3d0/gpu_busy_percentage | sed "s/ //g"`
gpuclk=`cat /sys/class/kgsl/kgsl-3d0/gpuclk`

printf "silver freq max: %-10s min: %-10s\n" $silver_max_freq $silver_min_freq
printf "gold freq max: %-10s min: %-10s\n\n" $gold_max_freq $gold_min_freq
printf "online cpus: %-10s %-10s %-10s %-10s %-10s %-10s %-10s %-10s\n"  $online_cpu0 $online_cpu1 $online_cpu2 $online_cpu3 $online_cpu4 $online_cpu5 $online_cpu6 $online_cpu7
printf "curre freqs: %-10s %-10s %-10s %-10s %-10s %-10s %-10s %-10s\n"  $cur_freq0 $cur_freq1 $cur_freq2 $cur_freq3 $cur_freq4 $cur_freq5 $cur_freq6 $cur_freq7
printf "gpu    info: %-10s %-10s\n\n\n" $gpubusy $gpuclk

top -b -n1 | head -n20
printf "\n\n\n"

sleep 1

done

GPU

高通平台的GPU相关信息在 /sys/class/devfreq 目录下,其中kgsl为高通的GPU节点。
如SM7150平台。其GPU节点为5000000.qcom,kgsl-3d0。

cat /sys/class/devfreq/5000000.qcom,kgsl-3d0/available_frequencies
180000000 267000000 355000000 430000000 504000000
cat /sys/class/devfreq/5000000.qcom,kgsl-3d0/max_freq
504000000
cat /sys/class/devfreq/5000000.qcom,kgsl-3d0/min_freq
180000000

其中max_freq跟min_freq分别代表当前governor设置的最高GPU频率和最低GPU频率。

设置 GPU 频率

  1. 在 sdm845-gpu.dtsi 中指定 power level 的等级

  2. 设置 gpu 节点的 power level

    • /sys/calss/kgsl/kgsl-3d0/min_pwrlevel
    • /sys/calss/kgsl/kgsl-3d0/max_pwrlevel
  3. powerhint 实现也是改变 gpu 的 pwrlevel

echo 0 > /sys/calss/kgsl/kgsl-3d0/min_pwrlevel
echo 0 > /sys/calss/kgsl/kgsl-3d0/max_pwrlevel

DDR 频率

/sys/kernel/debug/clk/measure_only_mccc_clk/clk_measure

# !/bin/sh
# SDM855
# delay of each event
if [ "$1" != "" ]; then
	delay=$1
else
	delay="0.01"
fi

# whole logging time
if [ "$2" != "" ]; then
	totaltime=$2
else
	totaltime=3600
fi
totalevents=$((totaltime*5))

if [ "$3" != "" ]; then
	perf_logging_log=$3
else
	perf_logging_log=/sdcard/perf_logging.csv
fi

#echo "$(uptime)" > $perf_logging_log
rm -f $perf_logging_log

echo "second,ddr_freq" >> $perf_logging_log

start=$(date +%s)	
n=0
while [ $n -lt $totalevents ];
do
	ddr_freq=$(cat /sys/kernel/debug/clk/measure_only_mccc_clk/clk_measure)
	
	end=$(date +%s)
	time=$(( $end - $start ))		
		
    echo "$time,$ddr_freq" >> $perf_logging_log
    sleep $delay
	n=$((n+1))
done

sensor

IMU 惯性测量单元是测量物体三轴姿态角(或角速率)以及加速度的装置。一般的,一个IMU包含了三个单轴的加速度计和三个单轴的陀螺,加速度计检测物体在载体坐标系统独立三轴的加速度信号,而陀螺检测载体相对于导航坐标系的角速度信号,测量物体在三维空间中的角速度和加速度,并以此解算出物体的姿态。

misc

CSI

CMOS Sensor Interface:相机串行接口。CSI接口通常从CMOS Sensor、Video Encoder和其它视频输出设备收集数据。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值