Documentation/driver-api/cxl/allocation/page-allocator.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API / CXL / Allocation

The Page Allocator

NUMA node, memory zone과 cpuset 구성이 CXL 페이지 할당에 미치는 영향을 설명합니다.

Source pathDocumentation/driver-api/cxl/allocation/page-allocator.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약과 해설

page-allocator.rst:1-85

NUMA node, memory zone과 cpuset 구성이 CXL 페이지 할당에 미치는 영향을 설명합니다. 영어 원문 전체와 한국어 전문 번역을 함께 제공하며 directive, 코드, symbol, source path와 원문 줄 좌표를 보존합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ==================
4 The Page Allocator
5 ==================
6
7 The kernel page allocator services all general page allocation requests, such
8 as :code:`kmalloc`. CXL configuration steps affect the behavior of the page
9 allocator based on the selected `Memory Zone` and `NUMA node` the capacity is
10 placed in.
11
12 This section mostly focuses on how these configurations affect the page
13 allocator (as of Linux v6.15) rather than the overall page allocator behavior.
14
15 NUMA nodes and mempolicy
16 ========================
17 Unless a task explicitly registers a mempolicy, the default memory policy
18 of the linux kernel is to allocate memory from the `local NUMA node` first,
19 and fall back to other nodes only if the local node is pressured.
20
21 Generally, we expect to see local DRAM and CXL memory on separate NUMA nodes,
22 with the CXL memory being non-local. Technically, however, it is possible
23 for a compute node to have no local DRAM, and for CXL memory to be the
24 `local` capacity for that compute node.
25
26
27 Memory Zones
28 ============
29 CXL capacity may be onlined in :code:`ZONE_NORMAL` or :code:`ZONE_MOVABLE`.
30
31 As of v6.15, the page allocator attempts to allocate from the highest
32 available and compatible ZONE for an allocation from the local node first.
33
34 An example of a `zone incompatibility` is attempting to service an allocation
35 marked :code:`GFP_KERNEL` from :code:`ZONE_MOVABLE`. Kernel allocations are
36 typically not migratable, and as a result can only be serviced from
37 :code:`ZONE_NORMAL` or lower.
38
39 To simplify this, the page allocator will prefer :code:`ZONE_MOVABLE` over
40 :code:`ZONE_NORMAL` by default, but if :code:`ZONE_MOVABLE` is depleted, it
41 will fallback to allocate from :code:`ZONE_NORMAL`.
42
43
44 Zone and Node Quirks
45 ====================
46 Let's consider a configuration where the local DRAM capacity is largely onlined
47 into :code:`ZONE_NORMAL`, with no :code:`ZONE_MOVABLE` capacity present. The
48 CXL capacity has the opposite configuration - all onlined in
49 :code:`ZONE_MOVABLE`.
50
51 Under the default allocation policy, the page allocator will completely skip
52 :code:`ZONE_MOVABLE` as a valid allocation target. This is because, as of
53 Linux v6.15, the page allocator does (approximately) the following: ::
54
55 for (each zone in local_node):
56
57 for (each node in fallback_order):
58
59 attempt_allocation(gfp_flags);
60
61 Because the local node does not have :code:`ZONE_MOVABLE`, the CXL node is
62 functionally unreachable for direct allocation. As a result, the only way
63 for CXL capacity to be used is via `demotion` in the reclaim path.
64
65 This configuration also means that if the DRAM ndoe has :code:`ZONE_MOVABLE`
66 capacity - when that capacity is depleted, the page allocator will actually
67 prefer CXL :code:`ZONE_MOVABLE` pages over DRAM :code:`ZONE_NORMAL` pages.
68
69 We may wish to invert this priority in future Linux versions.
70
71 If `demotion` and `swap` are disabled, Linux will begin to cause OOM crashes
72 when the DRAM nodes are depleted. See the reclaim section for more details.
73
74
75 CGroups and CPUSets
76 ===================
77 Finally, assuming CXL memory is reachable via the page allocation (i.e. onlined
78 in :code:`ZONE_NORMAL`), the :code:`cpusets.mems_allowed` may be used by
79 containers to limit the accessibility of certain NUMA nodes for tasks in that
80 container. Users may wish to utilize this in multi-tenant systems where some
81 tasks prefer not to use slower memory.
82
83 In the reclaim section we'll discuss some limitations of this interface to
84 prevent demotions of shared data to CXL memory (if demotions are enabled).
85
86

3. 한국어 전문 번역

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

Page allocator와 CXL 구성

1-14
.. SPDX-License-Identifier: GPL-2.0

커널 page allocator는 `kmalloc` 같은 모든 일반 페이지 할당 요청을 처리합니다. CXL 용량을 배치한 Memory Zone과 NUMA node 선택에 따라 CXL 구성 단계가 allocator의 동작에 영향을 줍니다.

이 절은 page allocator 전체 동작보다 Linux v6.15 기준으로 CXL 구성이 allocator에 미치는 영향에 초점을 맞춥니다.

NUMA node와 mempolicy

15-26

task가 mempolicy를 명시적으로 등록하지 않으면 Linux 커널의 기본 메모리 정책은 먼저 local NUMA node에서 메모리를 할당하고, local node가 압박을 받을 때만 다른 node로 fallback하는 것입니다.

일반적으로 local DRAM과 CXL 메모리는 별도의 NUMA node에 놓이고 CXL 메모리는 non-local일 것으로 예상합니다. 그러나 compute node에 local DRAM이 없고 CXL 메모리가 그 compute node의 local 용량이 되는 구성도 기술적으로 가능합니다.

Memory Zone 선택

27-43

CXL 용량은 `ZONE_NORMAL` 또는 `ZONE_MOVABLE`로 online할 수 있습니다. v6.15의 page allocator는 먼저 local node에서 할당과 호환되는 가장 높은 가용 ZONE을 사용하려고 합니다.

zone 비호환의 예는 `GFP_KERNEL`로 표시된 할당을 `ZONE_MOVABLE`에서 처리하려는 경우입니다. 커널 할당은 보통 이동할 수 없으므로 `ZONE_NORMAL` 이하에서만 처리할 수 있습니다.

단순화하면 page allocator는 기본적으로 `ZONE_NORMAL`보다 `ZONE_MOVABLE`을 선호하지만, `ZONE_MOVABLE`이 고갈되면 `ZONE_NORMAL`에서 할당하도록 fallback합니다.

Zone과 node 조합의 특이점

44-74

local DRAM 용량은 대부분 `ZONE_NORMAL`로 online되고 `ZONE_MOVABLE`은 없으며, 반대로 CXL 용량은 전부 `ZONE_MOVABLE`로 online된 구성을 생각해 볼 수 있습니다.

기본 정책에서는 page allocator가 `ZONE_MOVABLE`을 유효한 할당 대상으로 완전히 건너뜁니다. Linux v6.15의 allocator가 대략 다음 순서로 탐색하기 때문입니다.

for (each zone in local_node):

  for (each node in fallback_order):

    attempt_allocation(gfp_flags);

local node에 `ZONE_MOVABLE`이 없으므로 CXL node에는 직접 할당으로 도달할 수 없습니다. 결과적으로 CXL 용량은 reclaim 경로의 demotion을 통해서만 사용할 수 있습니다.

또한 DRAM node에 `ZONE_MOVABLE` 용량이 조금이라도 있고 그것이 고갈되면 allocator는 DRAM의 `ZONE_NORMAL` 페이지보다 CXL의 `ZONE_MOVABLE` 페이지를 우선합니다. 향후 Linux에서는 이 우선순위를 뒤집는 것이 바람직할 수 있습니다.

demotion과 swap을 모두 비활성화하면 DRAM node가 고갈될 때 Linux에서 OOM crash가 발생하기 시작합니다. 자세한 내용은 reclaim 절을 참고하십시오.

CGroup과 CPUSet

75-85

CXL 메모리가 page allocation을 통해 도달 가능한 경우, 즉 `ZONE_NORMAL`로 online된 경우 컨테이너는 `cpusets.mems_allowed`로 그 안의 task가 접근할 수 있는 NUMA node를 제한할 수 있습니다.

일부 task가 느린 메모리를 사용하지 않으려는 multi-tenant 시스템에서 이 기능을 활용할 수 있습니다. 다만 demotion이 활성화된 경우 공유 데이터가 CXL 메모리로 demote되는 것을 막는 데에는 한계가 있으며, reclaim 절에서 이를 설명합니다.