随笔-纵向优化-获取处理器参数
intel
x86 芯片有提供CPUID指令,输出结果为16进制的数据,按照特定的格式进行解析即可
直接可用的工具有:cpuid/lscpu/x86info、getconf -a| grep -i cache
参考:
intel CPUID instruction
ARM
工具:cat /proc/cpuinfo、lscpu
原理:
- https://www.kernel.org/doc/html/latest/arch/arm64/cpu-feature-registers.html
- https://developer.arm.com/documentation/100798/0401/AArch64-System-registers
比如解析MIDR-EL1(Main-ID-Register)
processor : 7
BogoMIPS : 48.00
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
cpu model : Rockchip RK3588
CPU implementer : 0x41
CPU architecture: 8 # arm-v8架构
CPU variant : 0x4
CPU part : 0xd0b # Cortex®‑A76 core.
CPU revision : 0
比如解析ID_AA64PFR0_EL1(PFR:Processor Feature Reg)/ID_AA64PFR1_EL1
比如解析CTR_EL0 Cache Type Register
获取缓存相关属性
本文来自博客园,作者:LiYanbin,转载请注明原文链接:https://www.cnblogs.com/stellar-liyanbin/p/18423299