基本概念
socket
主板上cpu插槽数目,通常也叫"路"。
core
核心,通常我们所指的双核、8核、16核就是指这个core。
NUMA
Non-uniform memory access (NUMA) is a computer memory design used in multiprocessing, where the memory access time depends on the memory location relative to the processor. Under NUMA, a processor can access its own local memory faster than non-local memory (memory local to another processor or memory shared between processors). The benefits of NUMA are limited to particular workloads, notably on servers where the data is often associated strongly with certain tasks or users.[1]
NUMA architectures logically follow in scaling from symmetric multiprocessing (SMP) architectures.
非统一内存访问NUMA 是一种用于多处理器的电脑内存体设计,内存访问时间取决于处理器的内存位置。 在NUMA下,处理器访问它自己的本地存储器的速度比非本地存储器(存储器的地方到另一个处理器之间共享的处理器或存储器)快一些。
NUMA架构在逻辑上遵循对称多处理(SMP)架构。
一个NUMA node包括一个或者多个Socket,以及与之相连的local memory。一个多核的Socket有多个Core。如果CPU支持HT,OS还会把这个Core看成 2个Logical Processor。
DIE/SoC
DIE一般指处理器的生产过程中,从晶圆上切割下来的小方块(CPU的芯片外表也是方的),在切割下来之前,每个DIE都经过各种加工,将电路刻在该DIE上。
MC
multi core的意思。
SMT
Simultaneous multithreading,简称SMT,也即同时多线程,注意区分和SMP的区别。SMT是一种在一个CPU的时钟周期内能够执行多个线程的指令的硬件多线程技术。
SMP
对称多处理器,Symmetric Multi-Processors,指计算机上汇集了一组处理器(多核),各个CPU之间共享内存子系统以及总线结构。
从调度域角度看:
sched_domain一般从近到远是SMT、MC、DIE、NUMA。
SMT:同一个物理core中的所有thread都在该调度域;
MC:同一个cluster中的所有物理core中的cpu都在该调度域;
DIE:包括Soc中的所有CPU;
NUMA:一般不会以NUMA node为调度域,太广泛了;
下图是一个举例:
查看cpu拓扑
以使用的服务器为例:其拓扑结构如下
Topology 2 Processors, 28 Cores, 56 Threads
node节点
numactl命令可以查看node节点信息
[root@localhost /]# numactl --hardware
available: 2 nodes (0-1) #有个node节点
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 28 29 30 31 32 33 34 35 36 37 38 39 40 41
node 0 size: 78848 MB
node 0 free: 836 MB
node 1 cpus: 14 15 16 17 18 19 20 21 22 23 24 25 26 27 42 43 44 45 46 47 48 49 50 51 52 53 54 55
node 1 size: 62091 MB
node 1 free: 289 MB
node distances: #表示跨node之间的距离,这里表示跨node之间访问成本是本node之内访问成本的2倍
node 0 1
0: 10 21
1: 21 10
查看node节点的详细信息
[root@localhost /]# ls /sys/devices/system/node/
has_cpu has_memory has_normal_memory node0 node1 online possible power uevent
查看node0节点
[root@localhost /]# ls /sys/devices/system/node/node0/
compact cpu12/ cpu3/ cpu34/ cpu39/ cpu6/ cpumap memory10/ memory15/ memory2/ memory24/ memory29/ memory33/ memory38/ memory6/ power/
cpu0/ cpu13/ cpu30/ cpu35/ cpu4/ cpu7/ distance memory11/ memory16/ memory20/ memory25/ memory3/ memory34/ memory39/ memory7/ subsystem/
cpu1/ cpu2/ cpu31/ cpu36/ cpu40/ cpu8/ hugepages/ memory12/ memory17/ memory21/ memory26/ memory30/ memory35/ memory4/ memory8/ uevent
cpu10/ cpu28/ cpu32/ cpu37/ cpu41/ cpu9/ meminfo memory13/ memory18/ memory22/ memory27/ memory31/ memory36/ memory40/ memory9/ vmstat
cpu11/ cpu29/ cpu33/ cpu38/ cpu5/ cpulist memory0/ memory14/ memory19/ memory23/ memory28/ memory32/ memory37/ memory5/ numastat
以cpu0举例:
index0: 1级数据cache
index1: 1级指令cache
index2: 2级cache
index3: 3级cache ,对应cpuinfo里的cache
目录里的文件是cache信息描述,以本机的cpu0/index0为例简单解释一下:
文件 | 内容 | 说明 |
---|---|---|
type | Data | 数据cache,如果查看index1就是Instruction |
Level | 1 | L1 |
Size | 32K | 大小为32K |
coherency_line_size | 64 | 644128=32K |
physical_line_partition | 1 | |
ways_of_associativity | 4 | |
number_of_sets | 128 | |
shared_cpu_map | 00000101 | 表示这个cache被CPU0和CPU8 share |
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index0/size
32K
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index1/size
32K
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index2/size
256K
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index3/size
35840K
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index0/shared_cpu_map
000000,10000001
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index1/shared_cpu_map
000000,10000001
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index2/shared_cpu_map
000000,10000001
[root@localhost /]# cat /sys/devices/system/node/node0/cpu0/cache/index3/shared_cpu_map
0003ff,f0003fff
[root@localhost /]# cat /sys/devices/system/node/node0/cpu28/cache/index0/shared_cpu_map
000000,10000001
[root@localhost /]# cat /sys/devices/system/node/node0/cpu28/cache/index1/shared_cpu_map
000000,10000001
[root@localhost /]# cat /sys/devices/system/node/node0/cpu28/cache/index2/shared_cpu_map
000000,10000001
[root@localhost /]# cat /sys/devices/system/node/node0/cpu28/cache/index3/shared_cpu_map
0003ff,f0003fff
[root@localhost /]# cat /sys/devices/system/node/node0/cpu2/cache/index3/shared_cpu_map
0003ff,f0003fff
processor/socket
[root@localhost /]# cat /proc/cpuinfo | grep "physical id" | cut -d: -f2 | sort -un
0
1
表示系统含有2个socket。
core
[root@localhost /]# cat /proc/cpuinfo | grep "cpu cores" | cut -d: -f2 | sort -un
14
说明系统每个socket上有14个cores。
[root@localhost /]# cat /proc/cpuinfo | grep "core id" | cut -d: -f2 | sort -un
0
1
2
3
4
5
6
8
9
10
11
12
13
14
但是core id不一定连续的,这里就没有core id “7”。
logical processor
[root@localhost /]# cat /proc/cpuinfo | grep "processor" | cut -d: -f2 | sort -un
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
OS认为有56个逻辑CPU,这是因为开启了HT超线程技术,每个core同时运行两个线程,让OS看做实际上有56个逻辑cpu。
/proc/cpuinfo
如果两个逻辑CPU是以下情况,属于同一核心core,是hyper-thread siblings。
- physical id相同
- core id相同
如果两个逻辑CPU是以下情况,属于同一核心physical pacakge,不同核心core,是core siblings。
- physcial id相同
- core id不同
sysfs查看
/sys/devices/system/cpu/cpuX/topology/
下也提供了和cpu核心相关的数据,如physical id, core id,core_siblings, thread_siblings等
拓扑图
最后,我根据我上面主机的信息,整理了主机的cpu拓扑结构图: