物理CPU、CPU内核、逻辑CPU概念与查看方法

概念区分

1. 物理CPU

即主板插槽上(物理封装上)的CPU芯片个数。物理cpu数量等于不同physical id的个数。

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

 

2. CPU内核数(cpu cores)

即一颗物理CPU包含的内核数量。一般来说,物理CPU个数 X cpu cores = 逻辑CPU个数。如果不相等则表示支持超线程技术。

查看命令# cat /proc/cpuinfo | grep "core id" | sort -u | wc -l    // CPU内核数

           或:# cat /proc/cpuinfo | grep "cpu cores" | uniq

 

3. 逻辑CPU

一般情况,一颗物理CPU可以有多个物理内核,加上intel的超线程技术(HT, Hyper-Threading)能够把一个物理处理器(内核)在软件层变成两个逻辑处理器,可以使处理器在某一时刻,同步并行处理更多指令和数据(多个线程),当然了实际效能不可实现双倍提升,毕竟干活的核心只有一个。

查看命令:# cat /proc/cpuinfo | grep "processor" | sort -u | wc -l    // 逻辑CPU个数(线程数)

 

关系

逻辑CPU数量 = 物理cpu数量 x 每颗物理CPU的内核数(cpu cores) x (siblings/cpu cores)

 

查看是否支持或打开超线程

查看CPU信息:# cat /proc/cpuinfo

  • 如果siblings = cpu cores,则不支持或未打开超线程
  • 如果siblings > cpu cores,则支持并已打开超线程,则siblings/cpu cores的值大于1

ps:

cpu cores 条目包含位于相同物理封装中的内核数量。

siblings 条目列出了位于相同物理封装中的逻辑处理器的数量。

 

 

查看CPU信息

  • linux系统: cat /proc/cpuinfo 或 lscpu
  • Windows系统:ctrl + alt + delete 打开“任务管理器”-->“性能”

操作

CentOS服务器查看CPU信息:(1CPU四核四线程)

[root@JavaWeb-host ~]# cat /proc/cpuinfo

processor : 0 # 逻辑CPU标号

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标号

siblings : 4 # 该逻辑CPU所在的物理CPU的逻辑CPU数量

core id : 0 # 内核标号

cpu cores : 4 # 该逻辑CPU所在的物理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@JavaWeb-host ~]# 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系统查看CPU信息:(1CPU两核四线程)

 

猜你喜欢

转载自www.cnblogs.com/iouwenbo/p/11348145.html