Linux查看CPU信息详解

Linux查看CPU信息

首先,大家如果看到有什么不懂的地方,欢迎吐槽!!!

参数说明:

  • Physical id 相同表示为同一个物理CPU
  • Processor 表示逻辑CPU
  • Cpu cores CPU核数,内核个数
  • Core id 内核id号
  • Siblings 每个物理CPU里面的逻辑CPU个数

物理CPU 两个

processor  0      processor  2       processor   4          processor   6
core id    0      core id    2       core id     1          core id     3
physical   0      physical   0       physical    0          physical    0
cpu cores  4      cpu cores  4       cpu cores   4          cpu cores   4
siblings   4      siblings   4        siblings   4          siblings    4

processor  1      processor  3       processor   5          processor   7
core id    0      core id    2       core id     1          core id     3
physical   1      physical   1       physical    1          physical    1
cpu cores  4      cpu cores  4       cpu cores   4          cpu cores   4
siblings   4      siblings   4       siblings   4           siblings    4

计算是否开启超线程

逻辑CPU  >  物理CPU  x   CPU核数  #开启超线程
逻辑CPU  =  物理CPU  x   CPU核数  #没有开启超线程或不支持超线程

查看物理CPU个数

cat /proc/cpuinfo | grep “physical id” | sort -u | wc -l
2

查看逻辑CPU个数

cat /proc/cpuinfo | grep “processor” | wc -l
8

查看CPU内核数

cat /proc/cpuinfo | grep “cpu cores” | uniq
4

查看单个物理CPU封装的逻辑CPU数量

cat /proc/cpuinfo | grep “siblings” | uniq
4

script查看CPU信息

#!/bin/bash

physical=$(cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l)
processor=$(cat /proc/cpuinfo | grep "processor" | wc -l)
cpucores=$(cat /proc/cpuinfo  | grep "cpu cores" | uniq)
siblings=$(cat /proc/cpuinfo  | grep "siblings"  | uniq)

echo "* * * * * CPU Information is a : * * * * *"
echo "physical id is a : $physical"
echo "processor is a   : $processor"
echo "cpu cores is a   : $cpucores"
echo "siblings is a    : $siblings"

判断CPU是32位的还是64位的

cat /proc/cpuinfo | grep lm 
8 flags     : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx tm2 ssse3 cx16 xtpr pdcm dca sse4_1 xsave lahf_lm dts tpr_shadow vnmi flexpriority
lm 表示Long Mode - 64位CPU

判断系统是32位的还是64位的

相关推荐