通过lscpu命令,可以看到CPU的一些基本信息。如下所示,可以很清楚的看到这台服务器使用两个物理socket,每个socket上有6个core,每个core上有两个线程(超线程),所以一共有2 * 6 * 2 = 24个逻辑CPU。
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 24
On-line CPU(s) list: 0-23
Thread(s) per core: 2
Core(s) per socket: 6
CPU socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Stepping: 4
CPU MHz: 2601.000
BogoMIPS: 5187.39
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 15360K
NUMA node0 CPU(s): 0-5,12-17
NUMA node1 CPU(s): 6-11,18-23
通过cat /proc/cpuinfo同样可以看到一些信息,这里会给socket、core和线程设置id。
同一个socket的physical id相同
cpu cores表示此socket上的core数量
如果cpu cores = siblings,表明没有开启超线程
如果cpu cores = 2 * siblings,表明开启了超线程
相同的physical id,相同的core id,但是不同的processor id,表明是同一个core上的逻辑CPU(超线程)
cpuinfo示例如下所示(原文引用已经找不到了,直接贴在这里)
Example 1: Single processor, 1 core, no Hyperthreading
Processor : 0
model name : AMD Duron(tm) processor
cache size : 64 KB
Example 2: Single processor, 1 core, Hyperthreading is enabled.
Notice how we have 2 siblings, but only 1 core. The physical CPU id is the same for both: 0.
processor : 0
model name : Intel(R) Pentium(R) 4 CPU 2.80GHz
cache size : 1024 KB
physical id : 0 # same physical id
siblings : 2
core id : 0 # same core id
cpu cores : 1
processor : 1
model name : Intel(R) Pentium(R) 4 CPU 2.80GHz
cache size : 1024 KB
physical id : 0 # same physical id
siblings : 2
core id : 0 # same core id
cpu cores : 1
Example 3. Single socket Quad Core
Notice how each processor has its own core id. The number of siblings matches the number of cores so there are no Hyperthreading siblings. Also notice the huge L2 cache - 6 MB. That makes sense though, when considering 4 cores share that L2 cache.
processor : 0
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0 # same physical id
siblings : 4
core id : 0 # different core id
cpu cores : 4
processor : 1
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0 # same physical id
siblings : 4
core id : 1 # different core id
cpu cores : 4
processor : 2
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0 # same physical id
siblings : 4
core id : 2 # different core id
cpu cores : 4
processor : 3
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0 # same physical id
siblings : 4
core id : 3 # different core id
cpu cores : 4
Example 3a. Single socket Dual Core
Again, each processor has its own core so this is a dual core system.
processor : 0
model name : Intel(R) Pentium(R) D CPU 3.00GHz
cache size : 2048 KB
physical id : 0 # same physical id
siblings : 2
core id : 0 # different core id
cpu cores : 2
processor : 1
model name : Intel(R) Pentium(R) D CPU 3.00GHz
cache size : 2048 KB
physical id : 0 # same physical id
siblings : 2
core id : 1 # different core id
cpu cores : 2
Example 4. Dual Single core CPU, Hyperthreading ENABLED
This example shows that processer 0 and 2 share the same physical CPU and 1 and 3 share the same physical CPU. The number of siblings is twice the number of cores, which is another clue that this is a system with hyperthreading enabled.
processor : 0
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 0 # different physical id
siblings : 2
core id : 0 # same core id
cpu cores : 1
processor : 1
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 3 # different physical id
siblings : 2
core id : 0 # same core id
cpu cores : 1
processor : 2
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 0 # different physical id
siblings : 2
core id : 0 # same core id
cpu cores : 1
processor : 3
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 3 # different physical id
siblings : 2
core id : 0 # same core id
cpu cores : 1
Example 5. Dual CPU Dual Core No hyperthreading
Of the 5 examples this should be the most capable system processor-wise. There are a total of 4 cores : 2 cores in 2 separate socketed physical CPUs. Each core shares the 4MB cache with its sibling core. The higher clock rate (3.0 GHz vs 2.3GHz) should offer slightly better
performance than example 3.
processor : 0
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 0 # different physical id
siblings : 2
core id : 0 # different core id
cpu cores : 2
processor : 1
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 0 # different physical id
siblings : 2
core id : 1 # different core id
cpu cores : 2
processor : 2
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 3 # different physical id
siblings : 2
core id : 0 # different core id
cpu cores : 2
processor : 3
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 3 # different physical id
siblings : 2
core id : 1 # different core id
cpu cores : 2