物理cpu个数
- grep ‘physical id’ /proc/cpuinfo |sort|uniq|wc -l
每个物理cpu的核心个数
- grep ‘cpu cores’ /proc/cpuinfo |uniq|awk -F ‘:’ ‘{print $2}’
每个物理cpu的逻辑cpu个数
- grep ‘siblings’ /proc/cpuinfo |sort|uniq|awk -F ‘:’ ‘{print $2}’
查看cpu是否开启超线程
- cat /proc/cpuinfo |grep -e ‘cpu cores’ -e ‘siblings’ |sort|uniq
- 若siblings = cpu cores,说明没有开启cpu超线程,如图:
- 若siblings = cpu cores * 2,说明cpu开启了超线程,超线程数为2,如图:
逻辑cpu个数
- grep ‘processor’ /proc/cpuinfo |sort|uniq|wc -l
总结
- 逻辑cpu=物理cpu * 每颗cpu核心数 * 超线程数