요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
=====================
Fake NUMA For CPUSets
=====================
:Author: David Rientjes <[email protected]>
Using numa=fake and CPUSets for Resource Management
This document describes how the numa=fake x86_64 command-line option can be used
in conjunction with cpusets for coarse memory management. Using this feature,
you can create fake NUMA nodes that represent contiguous chunks of memory and
assign them to cpusets and their attached tasks. This is a way of limiting the
amount of system memory that are available to a certain class of tasks.
For more information on the features of cpusets, see
Documentation/admin-guide/cgroup-v1/cpusets.rst.
There are a number of different configurations you can use for your needs. For
more information on the numa=fake command line option and its various ways of
configuring fake nodes, see Documentation/admin-guide/kernel-parameters.txt
For the purposes of this introduction, we'll assume a very primitive NUMA
emulation setup of "numa=fake=4*512,". This will split our system memory into
four equal chunks of 512M each that we can now use to assign to cpusets. As
you become more familiar with using this combination for resource control,
you'll determine a better setup to minimize the number of nodes you have to deal
with.
A machine may be split as follows with "numa=fake=4*512," as reported by dmesg::
Faking node 0 at 0000000000000000-0000000020000000 (512MB)
Faking node 1 at 0000000020000000-0000000040000000 (512MB)
Faking node 2 at 0000000040000000-0000000060000000 (512MB)
Faking node 3 at 0000000060000000-0000000080000000 (512MB)
...
On node 0 totalpages: 130975
On node 1 totalpages: 131072
On node 2 totalpages: 131072
On node 3 totalpages: 131072
Now following the instructions for mounting the cpusets filesystem from
Documentation/admin-guide/cgroup-v1/cpusets.rst, you can assign fake nodes (i.e. contiguous memory
address spaces) to individual cpusets::
[root@xroads /]# mkdir exampleset
[root@xroads /]# mount -t cpuset none exampleset
[root@xroads /]# mkdir exampleset/ddset
[root@xroads /]# cd exampleset/ddset
[root@xroads /exampleset/ddset]# echo 0-1 > cpus
[root@xroads /exampleset/ddset]# echo 0-1 > mems
Now this cpuset, 'ddset', will only allowed access to fake nodes 0 and 1 for
memory allocations (1G).
You can now assign tasks to these cpusets to limit the memory resources
available to them according to the fake nodes assigned as mems::
[root@xroads /exampleset/ddset]# echo $$ > tasks
[root@xroads /exampleset/ddset]# dd if=/dev/zero of=tmp bs=1024 count=1G
[1] 13425
Notice the difference between the system memory usage as reported by
/proc/meminfo between the restricted cpuset case above and the unrestricted
case (i.e. running the same 'dd' command without assigning it to a fake NUMA
cpuset):
======== ============ ==========
Name Unrestricted Restricted
======== ============ ==========
MemTotal 3091900 kB 3091900 kB
MemFree 42113 kB 1513236 kB
======== ============ ==========
This allows for coarse memory management for the tasks you assign to particular
cpusets. Since cpusets can form a hierarchy, you can create some pretty
interesting combinations of use-cases for various classes of tasks for your
memory management needs.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
numa=fake와 cpuset resource 관리
1-22이 문서는 `SPDX-License-Identifier: GPL-2.0`으로 배포되며 David Rientjes `<[email protected]>`가 작성했습니다.
`numa=fake` x86_64 command-line option을 cpuset과 함께 사용하면 coarse memory management를 구현할 수 있습니다. contiguous memory chunk를 나타내는 fake NUMA node를 만들고 cpuset 및 그에 연결된 task에 할당해 특정 task class가 사용할 수 있는 system memory 양을 제한합니다.
cpuset 기능은 `Documentation/admin-guide/cgroup-v1/cpusets.rst`를 참고하십시오. 여러 구성을 필요에 맞게 사용할 수 있으며 `numa=fake` option과 fake node 구성 방식은 `Documentation/admin-guide/kernel-parameters.txt`에 설명되어 있습니다.
4x512M fake node 구성
23-41이 소개에서는 단순한 NUMA emulation 설정 `numa=fake=4*512,`를 가정합니다. system memory를 각각 512M인 네 개의 같은 chunk로 나눠 cpuset에 할당할 수 있게 합니다. resource control에 익숙해지면 관리해야 할 node 수를 줄이는 더 나은 구성을 선택할 수 있습니다.
`numa=fake=4*512,`로 나눈 machine은 dmesg에 다음처럼 표시됩니다.
Faking node 0 at 0000000000000000-0000000020000000 (512MB)
Faking node 1 at 0000000020000000-0000000040000000 (512MB)
Faking node 2 at 0000000040000000-0000000060000000 (512MB)
Faking node 3 at 0000000060000000-0000000080000000 (512MB)
...
On node 0 totalpages: 130975
On node 1 totalpages: 131072
On node 2 totalpages: 131072
On node 3 totalpages: 131072
fake node를 cpuset에 할당
42-55`Documentation/admin-guide/cgroup-v1/cpusets.rst`의 cpuset filesystem mount 절차에 따라 fake node, 즉 contiguous memory address space를 개별 cpuset에 할당할 수 있습니다.
[root@xroads /]# mkdir exampleset
[root@xroads /]# mount -t cpuset none exampleset
[root@xroads /]# mkdir exampleset/ddset
[root@xroads /]# cd exampleset/ddset
[root@xroads /exampleset/ddset]# echo 0-1 > cpus
[root@xroads /exampleset/ddset]# echo 0-1 > mems
이제 `ddset` cpuset은 memory allocation에 fake node 0과 1만 사용할 수 있으므로 총 1G로 제한됩니다.
task 제한과 memory 사용량 비교
56-78task를 cpuset에 할당하면 `mems`로 지정한 fake node에 따라 사용할 수 있는 memory resource를 제한할 수 있습니다.
[root@xroads /exampleset/ddset]# echo $$ > tasks
[root@xroads /exampleset/ddset]# dd if=/dev/zero of=tmp bs=1024 count=1G
[1] 13425
위의 restricted cpuset과 같은 `dd` command를 fake NUMA cpuset에 할당하지 않고 실행한 unrestricted case에서 `/proc/meminfo`가 보고하는 system memory usage를 비교하면 다음과 같습니다.
| Name | Unrestricted | Restricted |
|---|---|---|
| `MemTotal` | `3091900 kB` | `3091900 kB` |
| `MemFree` | `42113 kB` | `1513236 kB` |
이 방식은 특정 cpuset에 배치한 task를 coarse하게 memory 관리할 수 있게 합니다. cpuset은 hierarchy를 구성할 수 있으므로 다양한 task class의 memory-management 요구에 맞는 여러 조합을 만들 수 있습니다.
요약과 해설
fake-numa-for-cpusets.rst:1-78`numa=fake=4*512,`는 memory를 512M짜리 fake NUMA node 네 개로 나눕니다. cpuset의 `mems`에 node를 지정하면 연결된 task가 allocate할 수 있는 memory 범위를 제한할 수 있습니다.
예제의 `ddset`은 node 0~1만 사용해 1G로 제한되며 `/proc/meminfo` 비교로 restricted task가 나머지 memory를 소비하지 못하는 결과를 확인합니다.