요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===========================================
Automatically bind swap device to numa node
===========================================
If the system has more than one swap device and swap device has the node
information, we can make use of this information to decide which swap
device to use in get_swap_pages() to get better performance.
How to use this feature
=======================
Swap device has priority and that decides the order of it to be used. To make
use of automatically binding, there is no need to manipulate priority settings
for swap devices. e.g. on a 2 node machine, assume 2 swap devices swapA and
swapB, with swapA attached to node 0 and swapB attached to node 1, are going
to be swapped on. Simply swapping them on by doing::
# swapon /dev/swapA
# swapon /dev/swapB
Then node 0 will use the two swap devices in the order of swapA then swapB and
node 1 will use the two swap devices in the order of swapB then swapA. Note
that the order of them being swapped on doesn't matter.
A more complex example on a 4 node machine. Assume 6 swap devices are going to
be swapped on: swapA and swapB are attached to node 0, swapC is attached to
node 1, swapD and swapE are attached to node 2 and swapF is attached to node3.
The way to swap them on is the same as above::
# swapon /dev/swapA
# swapon /dev/swapB
# swapon /dev/swapC
# swapon /dev/swapD
# swapon /dev/swapE
# swapon /dev/swapF
Then node 0 will use them in the order of::
swapA/swapB -> swapC -> swapD -> swapE -> swapF
swapA and swapB will be used in a round robin mode before any other swap device.
node 1 will use them in the order of::
swapC -> swapA -> swapB -> swapD -> swapE -> swapF
node 2 will use them in the order of::
swapD/swapE -> swapA -> swapB -> swapC -> swapF
Similaly, swapD and swapE will be used in a round robin mode before any
other swap devices.
node 3 will use them in the order of::
swapF -> swapA -> swapB -> swapC -> swapD -> swapE
Implementation details
======================
The current code uses a priority based list, swap_avail_list, to decide
which swap device to use and if multiple swap devices share the same
priority, they are used round robin. This change here replaces the single
global swap_avail_list with a per-numa-node list, i.e. for each numa node,
it sees its own priority based list of available swap devices. Swap
device's priority can be promoted on its matching node's swap_avail_list.
The current swap device's priority is set as: user can set a >=0 value,
or the system will pick one starting from -1 then downwards. The priority
value in the swap_avail_list is the negated value of the swap device's
due to plist being sorted from low to high. The new policy doesn't change
the semantics for priority >=0 cases, the previous starting from -1 then
downwards now becomes starting from -2 then downwards and -1 is reserved
as the promoted value. So if multiple swap devices are attached to the same
node, they will all be promoted to priority -1 on that node's plist and will
be used round robin before any other swap devices.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
NUMA node에 swap device 자동 연결
1-8System에 둘 이상의 swap device가 있고 각 device에 node 정보가 있다면, `get_swap_pages()`가 사용할 swap device를 고를 때 이 정보를 활용해 성능을 높일 수 있습니다.
두 node 구성
9-24Swap device에는 사용 순서를 결정하는 priority가 있습니다. 자동 연결을 사용하기 위해 swap device의 priority 설정을 따로 조작할 필요는 없습니다.
두 node system에서 swapA가 node 0, swapB가 node 1에 연결되어 있다고 가정합니다. 다음처럼 두 device를 단순히 활성화합니다.
# swapon /dev/swapA
# swapon /dev/swapB
그러면 node 0은 swapA 다음 swapB 순서로 사용하고, node 1은 swapB 다음 swapA 순서로 사용합니다. Device를 `swapon`한 순서는 결과에 영향을 주지 않습니다.
네 node 구성과 node 0
25-43더 복잡한 네 node system에서 swapA와 swapB는 node 0, swapC는 node 1, swapD와 swapE는 node 2, swapF는 node 3에 연결되어 있다고 가정합니다. 활성화 방법은 앞의 예와 같습니다.
# swapon /dev/swapA
# swapon /dev/swapB
# swapon /dev/swapC
# swapon /dev/swapD
# swapon /dev/swapE
# swapon /dev/swapF
Node 0의 사용 순서는 다음과 같습니다.
swapA/swapB -> swapC -> swapD -> swapE -> swapF
swapA와 swapB는 다른 swap device를 사용하기 전에 round robin 방식으로 사용됩니다.
Node 1부터 node 3까지의 순서
44-58Node 1의 사용 순서는 다음과 같습니다.
swapC -> swapA -> swapB -> swapD -> swapE -> swapF
Node 2의 사용 순서는 다음과 같습니다.
swapD/swapE -> swapA -> swapB -> swapC -> swapF
마찬가지로 swapD와 swapE는 다른 swap device보다 먼저 round robin 방식으로 사용됩니다.
Node 3의 사용 순서는 다음과 같습니다.
swapF -> swapA -> swapB -> swapC -> swapD -> swapE
| 요청 node | 먼저 사용하는 local group | 이후 fallback 순서 |
|---|---|---|
| node 0 | swapA / swapB | swapC → swapD → swapE → swapF |
| node 1 | swapC | swapA → swapB → swapD → swapE → swapF |
| node 2 | swapD / swapE | swapA → swapB → swapC → swapF |
| node 3 | swapF | swapA → swapB → swapC → swapD → swapE |
요청 node에 연결된 device 또는 동일-node group이 먼저 선택되며, group 안에서는 round robin으로 순환합니다.
Per-NUMA-node list 구현
59-69기존 code는 priority 기반 list인 `swap_avail_list`로 사용할 swap device를 결정하며, 같은 priority를 공유하는 device는 round robin으로 사용합니다.
이 변경은 하나의 global `swap_avail_list`를 per-numa-node list로 교체합니다. 각 NUMA node는 사용 가능한 swap device에 대한 자체 priority list를 보며, matching node의 `swap_avail_list`에서는 해당 swap device의 priority를 승격할 수 있습니다.
Priority 값의 의미
70-78사용자는 swap device priority에 `>=0` 값을 지정할 수 있고, 지정하지 않으면 system은 `-1`부터 아래로 감소하는 값을 선택합니다. `plist`가 낮은 값부터 높은 값으로 정렬되므로 `swap_avail_list`에 저장되는 priority 값은 swap device priority의 부호를 반대로 한 값입니다.
새 policy는 priority >=0의 의미를 바꾸지 않습니다. 기존에 `-1`부터 감소하던 자동 priority는 `-2`부터 감소하도록 바뀌고, `-1`은 promoted value로 예약됩니다. 따라서 같은 node에 연결된 여러 swap device는 그 node의 `plist`에서 모두 priority `-1`로 승격되어 다른 device보다 먼저 round robin으로 사용됩니다.
| 입력 또는 정책 | 값 | 의미 |
|---|---|---|
| 사용자 지정 `>=0` | 변경 없음 | 기존 priority semantics 유지 |
| 기존 자동 priority | `-1`부터 감소 | global list에서 자동 배정 |
| 새 자동 priority | `-2`부터 감소 | `-1`은 matching node의 promoted value로 예약 |
운영 핵심
swap_numa.rst:1-78NUMA-aware swap 선택은 별도 priority 설정 없이 현재 node에 연결된 swap device를 먼저 사용합니다. 동일 node의 device는 round robin으로 순환하고, per-node `swap_avail_list`에서 local device를 priority `-1`로 승격합니다.