← Documents Documentation/admin-guide/mm/numaperf.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Memory Management

NUMA Memory Performance

NUMA initiator-target locality, bandwidth·latency attribute와 memory-side cache sysfs 구조를 설명합니다.

Source pathDocumentation/admin-guide/mm/numaperf.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

운영 핵심

numaperf.rst:1-176

NUMA performance 정보는 단순한 node distance를 넘어 initiator-target별 access class, 정격 bandwidth·latency, memory-side cache hierarchy를 노출합니다. 값이 없다는 사실도 platform 또는 firmware discovery 상태를 판단하는 신호입니다.

관점핵심
Localityinitiator-target 관계를 access class와 상호 sysfs symlink로 표현
Performanceread/write bandwidth와 latency를 memory target의 initiator 경로에서 제공
Memory-side cachefar memory에서 CPU 쪽으로 갈수록 더 높은 cache level 번호 사용
Discoveryplatform이 ACPI HMAT 같은 정보를 제공할 때만 sysfs attribute 생성

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 =======================
2 NUMA Memory Performance
3 =======================
4
5 NUMA Locality
6 =============
7
8 Some platforms may have multiple types of memory attached to a compute
9 node. These disparate memory ranges may share some characteristics, such
10 as CPU cache coherence, but may have different performance. For example,
11 different media types and buses affect bandwidth and latency.
12
13 A system supports such heterogeneous memory by grouping each memory type
14 under different domains, or "nodes", based on locality and performance
15 characteristics. Some memory may share the same node as a CPU, and others
16 are provided as memory only nodes. While memory only nodes do not provide
17 CPUs, they may still be local to one or more compute nodes relative to
18 other nodes. The following diagram shows one such example of two compute
19 nodes with local memory and a memory only node for each of compute node::
20
21 +------------------+ +------------------+
22 | Compute Node 0 +-----+ Compute Node 1 |
23 | Local Node0 Mem | | Local Node1 Mem |
24 +--------+---------+ +--------+---------+
25 | |
26 +--------+---------+ +--------+---------+
27 | Slower Node2 Mem | | Slower Node3 Mem |
28 +------------------+ +--------+---------+
29
30 A "memory initiator" is a node containing one or more devices such as
31 CPUs or separate memory I/O devices that can initiate memory requests.
32 A "memory target" is a node containing one or more physical address
33 ranges accessible from one or more memory initiators.
34
35 When multiple memory initiators exist, they may not all have the same
36 performance when accessing a given memory target. Each initiator-target
37 pair may be organized into different ranked access classes to represent
38 this relationship. The highest performing initiator to a given target
39 is considered to be one of that target's local initiators, and given
40 the highest access class, 0. Any given target may have one or more
41 local initiators, and any given initiator may have multiple local
42 memory targets.
43
44 To aid applications matching memory targets with their initiators, the
45 kernel provides symlinks to each other. The following example lists the
46 relationship for the access class "0" memory initiators and targets::
47
48 # symlinks -v /sys/devices/system/node/nodeX/access0/targets/
49 relative: /sys/devices/system/node/nodeX/access0/targets/nodeY -> ../../nodeY
50
51 # symlinks -v /sys/devices/system/node/nodeY/access0/initiators/
52 relative: /sys/devices/system/node/nodeY/access0/initiators/nodeX -> ../../nodeX
53
54 A memory initiator may have multiple memory targets in the same access
55 class. The target memory's initiators in a given class indicate the
56 nodes' access characteristics share the same performance relative to other
57 linked initiator nodes. Each target within an initiator's access class,
58 though, do not necessarily perform the same as each other.
59
60 The access class "1" is used to allow differentiation between initiators
61 that are CPUs and hence suitable for generic task scheduling, and
62 IO initiators such as GPUs and NICs. Unlike access class 0, only
63 nodes containing CPUs are considered.
64
65 NUMA Performance
66 ================
67
68 Applications may wish to consider which node they want their memory to
69 be allocated from based on the node's performance characteristics. If
70 the system provides these attributes, the kernel exports them under the
71 node sysfs hierarchy by appending the attributes directory under the
72 memory node's access class 0 initiators as follows::
73
74 /sys/devices/system/node/nodeY/access0/initiators/
75
76 These attributes apply only when accessed from nodes that have the
77 are linked under the this access's initiators.
78
79 The performance characteristics the kernel provides for the local initiators
80 are exported are as follows::
81
82 # tree -P "read*|write*" /sys/devices/system/node/nodeY/access0/initiators/
83 /sys/devices/system/node/nodeY/access0/initiators/
84 |-- read_bandwidth
85 |-- read_latency
86 |-- write_bandwidth
87 `-- write_latency
88
89 The bandwidth attributes are provided in MiB/second.
90
91 The latency attributes are provided in nanoseconds.
92
93 The values reported here correspond to the rated latency and bandwidth
94 for the platform.
95
96 Access class 1 takes the same form but only includes values for CPU to
97 memory activity.
98
99 NUMA Cache
100 ==========
101
102 System memory may be constructed in a hierarchy of elements with various
103 performance characteristics in order to provide large address space of
104 slower performing memory cached by a smaller higher performing memory. The
105 system physical addresses memory initiators are aware of are provided
106 by the last memory level in the hierarchy. The system meanwhile uses
107 higher performing memory to transparently cache access to progressively
108 slower levels.
109
110 The term "far memory" is used to denote the last level memory in the
111 hierarchy. Each increasing cache level provides higher performing
112 initiator access, and the term "near memory" represents the fastest
113 cache provided by the system.
114
115 This numbering is different than CPU caches where the cache level (ex:
116 L1, L2, L3) uses the CPU-side view where each increased level is lower
117 performing. In contrast, the memory cache level is centric to the last
118 level memory, so the higher numbered cache level corresponds to memory
119 nearer to the CPU, and further from far memory.
120
121 The memory-side caches are not directly addressable by software. When
122 software accesses a system address, the system will return it from the
123 near memory cache if it is present. If it is not present, the system
124 accesses the next level of memory until there is either a hit in that
125 cache level, or it reaches far memory.
126
127 An application does not need to know about caching attributes in order
128 to use the system. Software may optionally query the memory cache
129 attributes in order to maximize the performance out of such a setup.
130 If the system provides a way for the kernel to discover this information,
131 for example with ACPI HMAT (Heterogeneous Memory Attribute Table),
132 the kernel will append these attributes to the NUMA node memory target.
133
134 When the kernel first registers a memory cache with a node, the kernel
135 will create the following directory::
136
137 /sys/devices/system/node/nodeX/memory_side_cache/
138
139 If that directory is not present, the system either does not provide
140 a memory-side cache, or that information is not accessible to the kernel.
141
142 The attributes for each level of cache is provided under its cache
143 level index::
144
145 /sys/devices/system/node/nodeX/memory_side_cache/indexA/
146 /sys/devices/system/node/nodeX/memory_side_cache/indexB/
147 /sys/devices/system/node/nodeX/memory_side_cache/indexC/
148
149 Each cache level's directory provides its attributes. For example, the
150 following shows a single cache level and the attributes available for
151 software to query::
152
153 # tree /sys/devices/system/node/node0/memory_side_cache/
154 /sys/devices/system/node/node0/memory_side_cache/
155 |-- index1
156 | |-- indexing
157 | |-- line_size
158 | |-- size
159 | `-- write_policy
160
161 The "indexing" will be 0 if it is a direct-mapped cache, and non-zero
162 for any other indexed based, multi-way associativity.
163
164 The "line_size" is the number of bytes accessed from the next cache
165 level on a miss.
166
167 The "size" is the number of bytes provided by this cache level.
168
169 The "write_policy" will be 0 for write-back, and non-zero for
170 write-through caching.
171
172 See Also
173 ========
174
175 [1] https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf
176 - Section 5.2.27
177

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

NUMA locality와 이기종 memory

1-19

일부 platform에서는 하나의 compute node에 여러 종류의 memory가 연결될 수 있습니다. 이 memory range들은 CPU cache coherence 같은 특성을 공유하면서도 media 종류와 bus 차이 때문에 bandwidth와 latency가 서로 다를 수 있습니다.

System은 locality와 performance 특성에 따라 memory 종류를 서로 다른 domain, 즉 node로 묶어 이러한 heterogeneous memory를 지원합니다. 어떤 memory는 CPU와 같은 node에 속하고, 다른 memory는 CPU가 없는 memory-only node로 제공됩니다. Memory-only node도 다른 node와 비교하면 하나 이상의 compute node에 local일 수 있습니다.

Compute node와 memory target 관계

20-42
Compute node별 local·slower memory topology
Compute Node 0 (Local Node0 Mem)Compute Node 1 (Local Node1 Mem)
Compute Node 0 (Local Node0 Mem)Slower Node2 Mem
Compute Node 1 (Local Node1 Mem)Slower Node3 Mem

두 compute node는 서로 연결되고, 각 compute node는 자체 local memory와 별도의 slower memory-only target을 가집니다.

용어정의관계
Compute nodeCPU 같은 memory request initiator를 포함하는 nodeLocal memory와 하나 이상의 memory-only target을 가까이 둘 수 있음
Memory-only nodeCPU 없이 physical address range만 제공하는 node상대적으로 하나 이상의 compute node에 local일 수 있음
Memory initiatorCPU 또는 별도 memory I/O device처럼 request를 시작하는 node하나 이상의 target에 접근
Memory targetinitiator가 접근할 수 있는 physical address range를 포함하는 node하나 이상의 local initiator를 가질 수 있음

Memory initiator가 여러 개이면 같은 memory target에 접근할 때도 성능이 모두 같지는 않을 수 있습니다. Kernel은 initiator-target pair를 순위가 있는 access class로 구성해 이 관계를 나타냅니다. 주어진 target에 가장 높은 성능을 내는 initiator는 그 target의 local initiator이며 가장 높은 access class 0을 받습니다.

하나의 target은 local initiator를 하나 이상 가질 수 있고, 하나의 initiator도 local memory target을 여러 개 가질 수 있습니다.

Access class와 상호 symlink

43-64

Application이 memory target과 initiator를 짝지을 수 있도록 kernel은 양쪽 node의 sysfs hierarchy에 서로를 가리키는 symlink를 제공합니다. 다음은 access class 0의 initiator와 target 관계를 양방향으로 조회한 예입니다.

# symlinks -v /sys/devices/system/node/nodeX/access0/targets/
relative: /sys/devices/system/node/nodeX/access0/targets/nodeY -> ../../nodeY

# symlinks -v /sys/devices/system/node/nodeY/access0/initiators/
relative: /sys/devices/system/node/nodeY/access0/initiators/nodeX -> ../../nodeX
Access class 0의 initiator-target 상호 연결
nodeX/access0/targets/nodeY../../nodeY
nodeY/access0/initiators/nodeX../../nodeX

Node X의 targets와 Node Y의 initiators가 상대 경로 symlink로 서로를 가리킵니다.

하나의 memory initiator에는 같은 access class에 속한 target이 여러 개 있을 수 있습니다. 주어진 class에 연결된 target의 initiator들은 다른 연결 initiator node에 대한 상대적 access 특성이 같다는 뜻입니다. 다만 같은 initiator class 안의 target들이 서로 완전히 같은 성능을 낸다는 뜻은 아닙니다.

Class의미포함 initiator
Access class 0주어진 target에 가장 높은 성능을 내는 local initiatorCPU와 GPU·NIC 같은 I/O initiator를 모두 표현
Access class 1generic task scheduling에 적합한 initiatorCPU를 포함하는 node만 고려

Access class 1은 CPU initiator와 GPU·NIC 같은 I/O initiator를 구분하기 위해 사용합니다. Access class 0과 달리 CPU를 포함해 generic task scheduling에 쓸 수 있는 node만 고려합니다.

NUMA performance attribute 경로

65-78

Application은 node의 performance 특성을 바탕으로 memory를 어느 node에서 할당할지 결정할 수 있습니다. Platform이 이 attribute를 제공하면 kernel은 memory node의 access class 0 initiator 아래에 attribute directory를 붙여 node sysfs hierarchy로 내보냅니다.

/sys/devices/system/node/nodeY/access0/initiators/

이 attribute 값은 해당 access의 `initiators` 아래에 symlink로 연결된 node에서 target에 접근할 때만 적용됩니다.

Bandwidth와 latency

79-98

Kernel이 local initiator에 제공하는 performance attribute는 다음 tree 출력과 같습니다.

# tree -P "read*|write*" /sys/devices/system/node/nodeY/access0/initiators/
/sys/devices/system/node/nodeY/access0/initiators/
|-- read_bandwidth
|-- read_latency
|-- write_bandwidth
`-- write_latency
Attribute측정 대상단위
read_bandwidthread bandwidthMiB/second
read_latencyread latencynanoseconds
write_bandwidthwrite bandwidthMiB/second
write_latencywrite latencynanoseconds

Bandwidth attribute의 단위는 MiB/second이고 latency attribute의 단위는 nanoseconds입니다. 보고 값은 platform의 정격 latency와 bandwidth에 해당합니다.

Access class 1도 같은 형식을 사용하지만 CPU에서 memory로 발생하는 activity 값만 포함합니다.

NUMA memory-side cache hierarchy

99-120

System memory는 작은 고성능 memory가 큰 저성능 memory를 cache하도록 여러 성능 계층으로 구성될 수 있습니다. Memory initiator가 인식하는 system physical address는 hierarchy의 마지막 memory level이 제공하고, system은 더 빠른 memory를 이용해 점차 느려지는 level에 대한 access를 투명하게 cache합니다.

`far memory`는 hierarchy의 마지막 level memory를 뜻합니다. Cache level이 높아질수록 initiator access 성능이 좋아지고, system이 제공하는 가장 빠른 cache를 `near memory`라고 합니다.

이 번호 체계는 CPU cache의 L1, L2, L3와 반대 방향입니다. CPU 관점에서는 level 번호가 커질수록 성능이 낮아지지만, memory-side cache는 마지막 level memory를 기준으로 하므로 번호가 클수록 CPU에 더 가깝고 far memory에서는 더 멉니다.

Cache access와 platform discovery

121-133

Memory-side cache는 software가 직접 address할 수 없습니다. Software가 system address에 접근하면 system은 data가 있을 경우 near memory cache에서 반환하고, 없으면 hit가 발생하거나 far memory에 도달할 때까지 다음 memory level로 이동합니다.

Application은 cache attribute를 몰라도 system을 사용할 수 있지만, 최대 성능을 얻기 위해 선택적으로 이 정보를 조회할 수 있습니다. ACPI HMAT(Heterogeneous Memory Attribute Table)처럼 kernel이 정보를 발견할 방법을 platform이 제공하면 kernel은 NUMA node memory target에 attribute를 추가합니다.

Memory-side cache sysfs directory

134-148

Kernel이 node에 memory cache를 처음 등록하면 다음 directory를 만듭니다.

/sys/devices/system/node/nodeX/memory_side_cache/

이 directory가 없으면 system이 memory-side cache를 제공하지 않거나 kernel이 그 정보를 읽을 수 없는 것입니다.

각 cache level의 attribute는 cache level index 아래에 제공됩니다.

/sys/devices/system/node/nodeX/memory_side_cache/indexA/
/sys/devices/system/node/nodeX/memory_side_cache/indexB/
/sys/devices/system/node/nodeX/memory_side_cache/indexC/

Cache level attribute

149-170

각 cache level directory에는 software가 조회할 수 있는 attribute가 있습니다. 다음 예는 cache level 하나와 그 attribute를 보여 줍니다.

# tree /sys/devices/system/node/node0/memory_side_cache/
/sys/devices/system/node/node0/memory_side_cache/
|-- index1
|   |-- indexing
|   |-- line_size
|   |-- size
|   `-- write_policy
Memory-side cache index 구조
계층하위 항목
memory_side_cache/index1/
index1/indexing, line_size, size, write_policy

`memory_side_cache` 아래의 level index가 해당 cache의 조회 attribute를 묶습니다.

Attribute의미
indexing0이면 direct-mapped, 0이 아니면 indexed multi-way associativity
line_sizecache miss 때 다음 cache level에서 읽는 byte 수
size해당 cache level이 제공하는 총 byte 수
write_policy0이면 write-back, 0이 아니면 write-through

`indexing`은 direct-mapped cache이면 0이고, 다른 indexed 방식이나 multi-way associativity이면 0이 아닙니다. `line_size`는 miss 때 다음 cache level에서 가져오는 byte 수이고, `size`는 해당 cache level이 제공하는 byte 수입니다. `write_policy`는 write-back이면 0이고 write-through이면 0이 아닙니다.

참고 자료

171-176

ACPI 6.2 specification의 Section 5.2.27에서 HMAT와 heterogeneous memory attribute의 firmware 표현을 확인할 수 있습니다.

원문 참고 자료: https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf, Section 5.2.27