cat /proc/cpuinfo命令部分輸出信息的含義node
physical id 物理封裝的處理器的id
processor 邏輯核的id
core id 一顆處理器中的每一個物理核的id
cpu cores 位於相同物理封裝的處理器中的物理核的數量
siblings 位於相同物理封裝的處理器中的邏輯核的數量
概念區分和查看方法linux
1. CPU(處理器)數量:主板插槽上(物理封裝上)的CPU芯片的個數api
在cat /proc/cpuinfo 命令的輸出中,每顆物理CPU都有惟一id號(即 physical id,從0開始標號),CPU數量即不一樣 physical id 的數量。服務器
因此,查看CPU數量的命令:socket
# cat /proc/cpuinfo | grep "physical id" // 查看全部的physical id,有多少個不一樣physical id就有多少顆CPU性能
# cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l // 查看不一樣physical id的數量,直接輸出CPU數量fetch
2. CPU物理核數(Core):一顆物理CPU中包含的內核數量(Core)
ui
在cat /proc/cpuinfo 命令的輸出中,每顆CPU裏的每一個物理核(核心,內核)都有id號(即 core id,從0開始標號)。相同物理封裝的CPU的物理核數即不一樣 core id 的數量。cpu cores的值也直接表示CPU物理核數。spa
因此,查看CPU物理核數的命令:線程
# cat /proc/cpuinfo | grep "cpu cores" // 查看cpu cores的值,即CPU物理核數
# cat /proc/cpuinfo | grep "core id" | sort -u | wc -l // 查看不一樣core id的數量,直接輸出CPU物理核數(注意:輸出的是一顆CPU的物理核數)
3. CPU邏輯核數(CPU線程數,Thread):經過超線程技術,能將一個物理核分紅多個邏輯核
通常狀況,一顆物理CPU能夠有多個物理內核,加上intel的超線程技術(HT, Hyper-Threading)可以把一個物理處理器(核心,內核)在軟件層變成兩個邏輯處理器,能夠使處理器在某一時刻,同步並行處理更多指令和數據(即有多個線程並行工做)。
在cat /proc/cpuinfo 命令的輸出中,processor的值表示邏輯處理器(邏輯核)的id號,CPU邏輯核數即不一樣 processor 的數量。
因此,查看CPU邏輯核數的命令:
# cat /proc/cpuinfo | grep "processor" | sort -u | wc -l // 查看不一樣 processor 的數量,直接輸出CPU邏輯核數總數(注意:輸出的是本服務器全部CPU的邏輯核的總數)
查看CPU是否支持超線程
命令:cat /proc/cpuinfo
若:
siblings = cpu cores 不支持超線程 或 未啓用超線程
siblings > cpu cores 支持並已啓用超線程
「siblings」指的是一顆物理CPU有幾個邏輯核,「cpu cores」指的是一顆物理CPU有幾個物理核。
計算服務器的物理核、邏輯核的總數
服務器的CPU物理核總數 = CPU數量 × 每顆CPU的物理核數(cpu cores)
服務器的CPU邏輯核總數 = CPU數量 × 每顆CPU的邏輯核數(siblings)
Linux和Windows查看CPU信息
- linux系統: cat /proc/cpuinfo 或 lscpu
- Windows系統:ctrl + alt + delete 打開「任務管理器」-->「性能」
============================== 分割線 ==================================
實際操做——分別在 CentOS 和 Windows10 查看CPU信息
一、CentOS(1 CPU四核四線程):
[root@localhost ~]# cat /proc/cpuinfo
processor : 0 # 邏輯核 id號
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0 # 物理CPU id號
siblings : 4 # 該邏輯核所在的物理CPU的邏輯核數
core id : 0 # 物理核 id號
cpu cores : 4 # 該邏輯核所在的物理CPU的物理核數
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0
siblings : 4
core id : 1
cpu cores : 4
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 2
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0
siblings : 4
core id : 2
cpu cores : 4
apicid : 2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 3
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2095.146
cache size : 16384 KB
physical id : 0
siblings : 4
core id : 3
cpu cores : 4
apicid : 3
initial apicid : 3
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
bogomips : 4190.29
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1 # 每一個物理核的線程數(邏輯核數)
Core(s) per socket: 4 # 每一個顆物理CPU的物理核數
Socket(s): 1 # 物理CPU插槽數
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 61
Model name: Intel Core Processor (Broadwell)
Stepping: 2
CPU MHz: 2095.146
BogoMIPS: 4190.29
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
L3 cache: 16384K
NUMA node0 CPU(s): 0-3
Flags: fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt arat
二、 Windows10(1 CPU兩核四線程):
ctrl + alt + delete 打開「任務管理器」,點擊「性能」
完~
2019.12.06更新