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

Linux 6.18.37 · Administration / Memory Management / DAMON

Getting Started

DAMON Operator로 접근 pattern snapshot·기록·heatmap·working-set 통계를 확인하고 DAMOS pageout action을 적용하는 시작 절차입니다.

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

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

1. 요약·해설

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

DAMON 시작 흐름

start.rst:1-178

DAMO를 이용해 workload를 관측하고 결과를 파일에 기록한 뒤, heatmap과 WSS로 해석하고 접근 패턴 조건에 맞는 pageout action까지 적용하는 최소 흐름을 보여 줍니다.

단계명령·조건확인 결과
준비`CONFIG_DAMON_*=y`, sysfs mountDAMON과 DAMO를 사용할 환경 확인
Snapshot`damo start`, `damo report access`현재 virtual address 접근 패턴 확인
Record`damo record -o damon.data`시간에 따른 접근 패턴 저장
Heatmap`damo report heatmap`주소·시간·접근 빈도를 2차원으로 확인
Working set`damo report wss`WSS 분포와 시간 변화 확인
Memory action`damo start --damos_*`접근 패턴 조건에 맞는 region pageout

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ===============
4 Getting Started
5 ===============
6
7 This document briefly describes how you can use DAMON by demonstrating its
8 default user space tool. Please note that this document describes only a part
9 of its features for brevity. Please refer to the usage `doc
10 <https://github.com/damonitor/damo/blob/next/USAGE.md>`_ of the tool for more
11 details.
12
13
14 Prerequisites
15 =============
16
17 Kernel
18 ------
19
20 You should first ensure your system is running on a kernel built with
21 ``CONFIG_DAMON_*=y``.
22
23
24 User Space Tool
25 ---------------
26
27 For the demonstration, we will use the default user space tool for DAMON,
28 called DAMON Operator (DAMO). It is available at
29 https://github.com/damonitor/damo. The examples below assume that ``damo`` is on
30 your ``$PATH``. It's not mandatory, though.
31
32 Because DAMO is using the sysfs interface (refer to :doc:`usage` for the
33 detail) of DAMON, you should ensure :doc:`sysfs </filesystems/sysfs>` is
34 mounted.
35
36
37 Snapshot Data Access Patterns
38 =============================
39
40 The commands below show the memory access pattern of a program at the moment of
41 the execution. ::
42
43 $ git clone https://github.com/sjp38/masim; cd masim; make
44 $ sudo damo start "./masim ./configs/stairs.cfg --quiet"
45 $ sudo damo report access
46 heatmap: 641111111000000000000000000000000000000000000000000000[...]33333333333333335557984444[...]7
47 # min/max temperatures: -1,840,000,000, 370,010,000, column size: 3.925 MiB
48 0 addr 86.182 TiB size 8.000 KiB access 0 % age 14.900 s
49 1 addr 86.182 TiB size 8.000 KiB access 60 % age 0 ns
50 2 addr 86.182 TiB size 3.422 MiB access 0 % age 4.100 s
51 3 addr 86.182 TiB size 2.004 MiB access 95 % age 2.200 s
52 4 addr 86.182 TiB size 29.688 MiB access 0 % age 14.100 s
53 5 addr 86.182 TiB size 29.516 MiB access 0 % age 16.700 s
54 6 addr 86.182 TiB size 29.633 MiB access 0 % age 17.900 s
55 7 addr 86.182 TiB size 117.652 MiB access 0 % age 18.400 s
56 8 addr 126.990 TiB size 62.332 MiB access 0 % age 9.500 s
57 9 addr 126.990 TiB size 13.980 MiB access 0 % age 5.200 s
58 10 addr 126.990 TiB size 9.539 MiB access 100 % age 3.700 s
59 11 addr 126.990 TiB size 16.098 MiB access 0 % age 6.400 s
60 12 addr 127.987 TiB size 132.000 KiB access 0 % age 2.900 s
61 total size: 314.008 MiB
62 $ sudo damo stop
63
64 The first command of the above example downloads and builds an artificial
65 memory access generator program called ``masim``. The second command asks DAMO
66 to start the program via the given command and make DAMON monitors the newly
67 started process. The third command retrieves the current snapshot of the
68 monitored access pattern of the process from DAMON and shows the pattern in a
69 human readable format.
70
71 The first line of the output shows the relative access temperature (hotness) of
72 the regions in a single row hetmap format. Each column on the heatmap
73 represents regions of same size on the monitored virtual address space. The
74 position of the colun on the row and the number on the column represents the
75 relative location and access temperature of the region. ``[...]`` means
76 unmapped huge regions on the virtual address spaces. The second line shows
77 additional information for better understanding the heatmap.
78
79 Each line of the output from the third line shows which virtual address range
80 (``addr XX size XX``) of the process is how frequently (``access XX %``)
81 accessed for how long time (``age XX``). For example, the evelenth region of
82 ~9.5 MiB size is being most frequently accessed for last 3.7 seconds. Finally,
83 the fourth command stops DAMON.
84
85 Note that DAMON can monitor not only virtual address spaces but multiple types
86 of address spaces including the physical address space.
87
88
89 Recording Data Access Patterns
90 ==============================
91
92 The commands below record the memory access patterns of a program and save the
93 monitoring results to a file. ::
94
95 $ ./masim ./configs/zigzag.cfg &
96 $ sudo damo record -o damon.data $(pidof masim)
97
98 The line of the commands run the artificial memory access
99 generator program again. The generator will repeatedly
100 access two 100 MiB sized memory regions one by one. You can substitute this
101 with your real workload. The last line asks ``damo`` to record the access
102 pattern in the ``damon.data`` file.
103
104
105 Visualizing Recorded Patterns
106 =============================
107
108 You can visualize the pattern in a heatmap, showing which memory region
109 (x-axis) got accessed when (y-axis) and how frequently (number).::
110
111 $ sudo damo report heatmap
112 22222222222222222222222222222222222222211111111111111111111111111111111111111100
113 44444444444444444444444444444444444444434444444444444444444444444444444444443200
114 44444444444444444444444444444444444444433444444444444444444444444444444444444200
115 33333333333333333333333333333333333333344555555555555555555555555555555555555200
116 33333333333333333333333333333333333344444444444444444444444444444444444444444200
117 22222222222222222222222222222222222223355555555555555555555555555555555555555200
118 00000000000000000000000000000000000000288888888888888888888888888888888888888400
119 00000000000000000000000000000000000000288888888888888888888888888888888888888400
120 33333333333333333333333333333333333333355555555555555555555555555555555555555200
121 88888888888888888888888888888888888888600000000000000000000000000000000000000000
122 88888888888888888888888888888888888888600000000000000000000000000000000000000000
123 33333333333333333333333333333333333333444444444444444444444444444444444444443200
124 00000000000000000000000000000000000000288888888888888888888888888888888888888400
125 [...]
126 # access_frequency: 0 1 2 3 4 5 6 7 8 9
127 # x-axis: space (139728247021568-139728453431248: 196.848 MiB)
128 # y-axis: time (15256597248362-15326899978162: 1 m 10.303 s)
129 # resolution: 80x40 (2.461 MiB and 1.758 s for each character)
130
131 You can also visualize the distribution of the working set size, sorted by the
132 size.::
133
134 $ sudo damo report wss --range 0 101 10
135 # <percentile> <wss>
136 # target_id 18446632103789443072
137 # avr: 107.708 MiB
138 0 0 B | |
139 10 95.328 MiB |**************************** |
140 20 95.332 MiB |**************************** |
141 30 95.340 MiB |**************************** |
142 40 95.387 MiB |**************************** |
143 50 95.387 MiB |**************************** |
144 60 95.398 MiB |**************************** |
145 70 95.398 MiB |**************************** |
146 80 95.504 MiB |**************************** |
147 90 190.703 MiB |********************************************************* |
148 100 196.875 MiB |***********************************************************|
149
150 Using ``--sortby`` option with the above command, you can show how the working
151 set size has chronologically changed.::
152
153 $ sudo damo report wss --range 0 101 10 --sortby time
154 # <percentile> <wss>
155 # target_id 18446632103789443072
156 # avr: 107.708 MiB
157 0 3.051 MiB | |
158 10 190.703 MiB |***********************************************************|
159 20 95.336 MiB |***************************** |
160 30 95.328 MiB |***************************** |
161 40 95.387 MiB |***************************** |
162 50 95.332 MiB |***************************** |
163 60 95.320 MiB |***************************** |
164 70 95.398 MiB |***************************** |
165 80 95.398 MiB |***************************** |
166 90 95.340 MiB |***************************** |
167 100 95.398 MiB |***************************** |
168
169
170 Data Access Pattern Aware Memory Management
171 ===========================================
172
173 Below command makes every memory region of size >=4K that has not accessed for
174 >=60 seconds in your workload to be swapped out. ::
175
176 $ sudo damo start --damos_access_rate 0 0 --damos_sz_region 4K max \
177 --damos_age 60s max --damos_action pageout \
178 --target_pid <pid of your workload>
179

3. 한국어 전문 번역

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

시작하기

1-12

이 문서는 GPL-2.0 라이선스를 따릅니다. DAMON의 기본 user-space 도구를 시연하면서 DAMON 사용 방법을 짧게 소개합니다. 간결하게 설명하기 위해 기능 일부만 다루므로, 자세한 내용은 도구의 usage 문서를 참조해야 합니다.

사전 요구 사항

13-35

먼저 `CONFIG_DAMON_*=y`로 빌드한 kernel을 실행하고 있는지 확인합니다.

시연에는 DAMON의 기본 user-space 도구인 DAMON Operator(`DAMO`)를 사용합니다. 예제는 `damo`가 `$PATH`에 있다고 가정하지만 필수 조건은 아닙니다.

DAMO는 DAMON의 sysfs interface를 사용하므로 sysfs가 mount되어 있어야 합니다. interface의 세부 사항은 DAMON `usage` 문서와 `/filesystems/sysfs` 문서를 참조합니다.

Data access pattern snapshot

36-88

다음 명령은 실행 시점에 program의 memory access pattern을 보여 줍니다. 첫 명령은 인공 memory access generator인 `masim`을 내려받아 build합니다. 두 번째 명령은 DAMO가 지정한 command로 program을 시작하고 새 process를 DAMON이 관측하게 합니다. 세 번째 명령은 현재 snapshot을 가져와 사람이 읽을 수 있는 형식으로 표시하고, 네 번째 명령은 DAMON을 중지합니다.

$ git clone https://github.com/sjp38/masim; cd masim; make
$ sudo damo start "./masim ./configs/stairs.cfg --quiet"
$ sudo damo report access
heatmap: 641111111000000000000000000000000000000000000000000000[...]33333333333333335557984444[...]7
# min/max temperatures: -1,840,000,000, 370,010,000, column size: 3.925 MiB
0   addr 86.182 TiB   size 8.000 KiB   access 0 %   age 14.900 s
1   addr 86.182 TiB   size 8.000 KiB   access 60 %  age 0 ns
2   addr 86.182 TiB   size 3.422 MiB   access 0 %   age 4.100 s
3   addr 86.182 TiB   size 2.004 MiB   access 95 %  age 2.200 s
4   addr 86.182 TiB   size 29.688 MiB  access 0 %   age 14.100 s
5   addr 86.182 TiB   size 29.516 MiB  access 0 %   age 16.700 s
6   addr 86.182 TiB   size 29.633 MiB  access 0 %   age 17.900 s
7   addr 86.182 TiB   size 117.652 MiB access 0 %   age 18.400 s
8   addr 126.990 TiB  size 62.332 MiB  access 0 %   age 9.500 s
9   addr 126.990 TiB  size 13.980 MiB  access 0 %   age 5.200 s
10  addr 126.990 TiB  size 9.539 MiB   access 100 % age 3.700 s
11  addr 126.990 TiB  size 16.098 MiB  access 0 %   age 6.400 s
12  addr 127.987 TiB  size 132.000 KiB access 0 %   age 2.900 s
total size: 314.008 MiB
$ sudo damo stop

출력 첫 줄은 region의 상대적 access temperature를 한 줄 heatmap으로 나타냅니다. 각 column은 관측한 virtual address space에서 같은 크기의 region을 나타내고, column의 위치와 숫자는 region의 상대 위치와 온도를 뜻합니다. `[...]`는 virtual address space에서 mapping되지 않은 거대한 영역이며, 두 번째 줄은 heatmap 해석을 돕는 추가 정보입니다.

세 번째 줄부터는 각 virtual address 범위(`addr XX size XX`)가 얼마나 자주(`access XX %`) 얼마 동안(`age XX`) 접근됐는지를 보여 줍니다. 예를 들어 index 10의 약 9.5 MiB region은 최근 3.7초 동안 가장 자주 접근됐습니다. 전체 관측 크기는 314.008 MiB입니다.

Snapshot region 구조화 보기
IndexAddressSizeAccessAge
086.182 TiB8.000 KiB0 %14.900 s
186.182 TiB8.000 KiB60 %0 ns
286.182 TiB3.422 MiB0 %4.100 s
386.182 TiB2.004 MiB95 %2.200 s
486.182 TiB29.688 MiB0 %14.100 s
586.182 TiB29.516 MiB0 %16.700 s
686.182 TiB29.633 MiB0 %17.900 s
786.182 TiB117.652 MiB0 %18.400 s
8126.990 TiB62.332 MiB0 %9.500 s
9126.990 TiB13.980 MiB0 %5.200 s
10126.990 TiB9.539 MiB100 %3.700 s
11126.990 TiB16.098 MiB0 %6.400 s
12127.987 TiB132.000 KiB0 %2.900 s
Heatmap각 column은 같은 크기의 virtual address region이며 숫자는 상대적 access temperature입니다.
Address spacesDAMON은 virtual address뿐 아니라 physical address를 포함한 여러 address space 유형도 관측할 수 있습니다.

원문의 13개 region 출력을 address, size, access frequency, age 열로 다시 배열했습니다.

DAMON은 virtual address space만이 아니라 physical address space를 포함한 여러 종류의 address space를 관측할 수 있습니다.

Data access pattern 기록

89-104

다음 명령은 program의 memory access pattern을 기록하고 결과를 파일에 저장합니다.

$ ./masim ./configs/zigzag.cfg &
$ sudo damo record -o damon.data $(pidof masim)

첫 줄은 인공 memory access generator를 다시 실행합니다. generator는 100 MiB 크기의 memory region 두 개를 하나씩 번갈아 반복 접근합니다. 실제 workload로 바꿔도 됩니다. 마지막 줄은 `damo`에 접근 패턴을 `damon.data` 파일로 기록하라고 요청합니다.

기록된 pattern을 heatmap으로 시각화

105-130

heatmap은 어느 memory region이 x-axis의 어디에 있고, y-axis의 어느 시점에 얼마나 자주 접근됐는지를 숫자로 보여 줍니다.

$ sudo damo report heatmap
22222222222222222222222222222222222222211111111111111111111111111111111111111100
44444444444444444444444444444444444444434444444444444444444444444444444444443200
44444444444444444444444444444444444444433444444444444444444444444444444444444200
33333333333333333333333333333333333333344555555555555555555555555555555555555200
33333333333333333333333333333333333344444444444444444444444444444444444444444200
22222222222222222222222222222222222223355555555555555555555555555555555555555200
00000000000000000000000000000000000000288888888888888888888888888888888888888400
00000000000000000000000000000000000000288888888888888888888888888888888888888400
33333333333333333333333333333333333333355555555555555555555555555555555555555200
88888888888888888888888888888888888888600000000000000000000000000000000000000000
88888888888888888888888888888888888888600000000000000000000000000000000000000000
33333333333333333333333333333333333333444444444444444444444444444444444444443200
00000000000000000000000000000000000000288888888888888888888888888888888888888400
[...]
# access_frequency:  0  1  2  3  4  5  6  7  8  9
# x-axis: space (139728247021568-139728453431248: 196.848 MiB)
# y-axis: time (15256597248362-15326899978162: 1 m 10.303 s)
# resolution: 80x40 (2.461 MiB and 1.758 s for each character)
Heatmap 축과 해상도
요소원문 값의미
Access frequencydigit 0-90은 차가움, 9는 뜨거움
x-axis139728247021568-139728453431248196.848 MiB address space
y-axis15256597248362-153268999781621 m 10.303 s monitoring time
Resolution80 x 40문자 하나당 2.461 MiB / 1.758 s
Raster각 문자는 한 address-space 구간과 한 time 구간의 access frequency를 0-9로 표현합니다.
[...]출력에서 생략된 heatmap 행이 있음을 뜻합니다.

원문 ASCII heatmap의 숫자 범례와 x/y축 좌표, 문자 하나의 해상도를 구조화했습니다.

크기순 working set 분포

131-149

working set size(WSS) 분포를 크기순으로 정렬해 시각화할 수도 있습니다. 다음 출력은 `--range 0 101 10`으로 0th부터 100th percentile까지 10 단위로 보여 주며, 평균 WSS는 107.708 MiB입니다.

$ sudo damo report wss --range 0 101 10
# <percentile> <wss>
# target_id     18446632103789443072
# avr:  107.708 MiB
  0             0 B |                                                           |
 10      95.328 MiB |****************************                               |
 20      95.332 MiB |****************************                               |
 30      95.340 MiB |****************************                               |
 40      95.387 MiB |****************************                               |
 50      95.387 MiB |****************************                               |
 60      95.398 MiB |****************************                               |
 70      95.398 MiB |****************************                               |
 80      95.504 MiB |****************************                               |
 90     190.703 MiB |*********************************************************  |
100     196.875 MiB |***********************************************************|
Working set size percentile
PercentileWSS
00 B
1095.328 MiB
2095.332 MiB
3095.340 MiB
4095.387 MiB
5095.387 MiB
6095.398 MiB
7095.398 MiB
8095.504 MiB
90190.703 MiB
100196.875 MiB
Average107.708 MiB
Target ID18446632103789443072

원문의 ASCII bar 길이 대신 각 percentile의 정확한 WSS 값을 표로 다시 그렸습니다.

시간순 working set 변화

150-168

같은 command에 `--sortby time`을 사용하면 working set size가 시간 순서에 따라 어떻게 변했는지 표시합니다. 이때 percentile 열은 시간 진행 순서를 나타내며 평균 WSS는 같은 107.708 MiB입니다.

$ sudo damo report wss --range 0 101 10 --sortby time
# <percentile> <wss>
# target_id     18446632103789443072
# avr:  107.708 MiB
  0       3.051 MiB |                                                           |
 10     190.703 MiB |***********************************************************|
 20      95.336 MiB |*****************************                              |
 30      95.328 MiB |*****************************                              |
 40      95.387 MiB |*****************************                              |
 50      95.332 MiB |*****************************                              |
 60      95.320 MiB |*****************************                              |
 70      95.398 MiB |*****************************                              |
 80      95.398 MiB |*****************************                              |
 90      95.340 MiB |*****************************                              |
100      95.398 MiB |*****************************                              |
시간에 따른 working set size
Time percentileWSS
03.051 MiB
10190.703 MiB
2095.336 MiB
3095.328 MiB
4095.387 MiB
5095.332 MiB
6095.320 MiB
7095.398 MiB
8095.398 MiB
9095.340 MiB
10095.398 MiB
Average107.708 MiB
Ordering--sortby time

원문의 ASCII bar를 시간 진행 percentile과 WSS 값의 구조화 표로 다시 그렸습니다.

Data access pattern-aware memory management

169-178

다음 명령은 workload에서 크기가 4 KiB 이상이고 60초 이상 접근되지 않은 모든 memory region을 swap out합니다. `--damos_access_rate 0 0`, `--damos_sz_region 4K max`, `--damos_age 60s max`가 대상을 고르고 `--damos_action pageout`이 적용할 action을 정합니다.

$ sudo damo start --damos_access_rate 0 0 --damos_sz_region 4K max \
                  --damos_age 60s max --damos_action pageout \
                  --target_pid <pid of your workload>