@@ -7,37 +7,40 @@ Detailed Usages
7
7
DAMON provides below three interfaces for different users.
8
8
9
9
- *DAMON user space tool. *
10
- This is for privileged people such as system administrators who want a
11
- just-working human-friendly interface. Using this, users can use the DAMON’s
12
- major features in a human-friendly way. It may not be highly tuned for
13
- special cases, though. It supports both virtual and physical address spaces
14
- monitoring.
10
+ `This <https://github.com/awslabs/damo >`_ is for privileged people such as
11
+ system administrators who want a just-working human-friendly interface.
12
+ Using this, users can use the DAMON’s major features in a human-friendly way.
13
+ It may not be highly tuned for special cases, though. It supports both
14
+ virtual and physical address spaces monitoring. For more detail, please
15
+ refer to its `usage document
16
+ <https://github.com/awslabs/damo/blob/next/USAGE.md> `_.
15
17
- *debugfs interface. *
16
- This is for privileged user space programmers who want more optimized use of
17
- DAMON. Using this, users can use DAMON’s major features by reading
18
- from and writing to special debugfs files. Therefore, you can write and use
19
- your personalized DAMON debugfs wrapper programs that reads/writes the
20
- debugfs files instead of you. The DAMON user space tool is also a reference
21
- implementation of such programs. It supports both virtual and physical
22
- address spaces monitoring.
18
+ :ref: `This <debugfs_interface >` is for privileged user space programmers who
19
+ want more optimized use of DAMON. Using this, users can use DAMON’s major
20
+ features by reading from and writing to special debugfs files. Therefore,
21
+ you can write and use your personalized DAMON debugfs wrapper programs that
22
+ reads/writes the debugfs files instead of you. The `DAMON user space tool
23
+ <https://github.com/awslabs/damo> `_ is one example of such programs. It
24
+ supports both virtual and physical address spaces monitoring. Note that this
25
+ interface provides only simple :ref: `statistics <damos_stats >` for the
26
+ monitoring results. For detailed monitoring results, DAMON provides a
27
+ :ref: `tracepoint <tracepoint >`.
23
28
- *Kernel Space Programming Interface. *
24
- This is for kernel space programmers. Using this, users can utilize every
25
- feature of DAMON most flexibly and efficiently by writing kernel space
26
- DAMON application programs for you. You can even extend DAMON for various
27
- address spaces.
29
+ :doc: `This </vm/damon/api >` is for kernel space programmers. Using this,
30
+ users can utilize every feature of DAMON most flexibly and efficiently by
31
+ writing kernel space DAMON application programs for you. You can even extend
32
+ DAMON for various address spaces. For detail, please refer to the interface
33
+ :doc: `document </vm/damon/api >`.
28
34
29
- Nevertheless, you could write your own user space tool using the debugfs
30
- interface. A reference implementation is available at
31
- https://github.com/awslabs/damo. If you are a kernel programmer, you could
32
- refer to :doc: `/vm/damon/api ` for the kernel space programming interface. For
33
- the reason, this document describes only the debugfs interface
35
+
36
+ .. _debugfs_interface :
34
37
35
38
debugfs Interface
36
39
=================
37
40
38
- DAMON exports five files, ``attrs ``, ``target_ids ``, ``init_regions ``,
39
- ``schemes `` and ``monitor_on `` under its debugfs directory,
40
- ``<debugfs>/damon/ ``.
41
+ DAMON exports eight files, ``attrs ``, ``target_ids ``, ``init_regions ``,
42
+ ``schemes ``, ``monitor_on ``, `` kdamond_pid ``, `` mk_contexts `` and
43
+ ``rm_contexts `` under its debugfs directory, `` <debugfs>/damon/ ``.
41
44
42
45
43
46
Attributes
@@ -131,24 +134,38 @@ Schemes
131
134
132
135
For usual DAMON-based data access aware memory management optimizations, users
133
136
would simply want the system to apply a memory management action to a memory
134
- region of a specific size having a specific access frequency for a specific
135
- time. DAMON receives such formalized operation schemes from the user and
136
- applies those to the target processes. It also counts the total number and
137
- size of regions that each scheme is applied. This statistics can be used for
138
- online analysis or tuning of the schemes.
137
+ region of a specific access pattern. DAMON receives such formalized operation
138
+ schemes from the user and applies those to the target processes.
139
139
140
140
Users can get and set the schemes by reading from and writing to ``schemes ``
141
141
debugfs file. Reading the file also shows the statistics of each scheme. To
142
- the file, each of the schemes should be represented in each line in below form:
142
+ the file, each of the schemes should be represented in each line in below
143
+ form::
144
+
145
+ <target access pattern> <action> <quota> <watermarks>
146
+
147
+ You can disable schemes by simply writing an empty string to the file.
148
+
149
+ Target Access Pattern
150
+ ~~~~~~~~~~~~~~~~~~~~~
151
+
152
+ The ``<target access pattern> `` is constructed with three ranges in below
153
+ form::
154
+
155
+ min-size max-size min-acc max-acc min-age max-age
143
156
144
- min-size max-size min-acc max-acc min-age max-age action
157
+ Specifically, bytes for the size of regions (``min-size `` and ``max-size ``),
158
+ number of monitored accesses per aggregate interval for access frequency
159
+ (``min-acc `` and ``max-acc ``), number of aggregate intervals for the age of
160
+ regions (``min-age `` and ``max-age ``) are specified. Note that the ranges are
161
+ closed interval.
145
162
146
- Note that the ranges are closed interval. Bytes for the size of regions
147
- (`` min-size `` and `` max-size ``), number of monitored accesses per aggregate
148
- interval for access frequency (`` min-acc `` and `` max-acc ``), number of
149
- aggregate intervals for the age of regions (`` min-age `` and `` max-age ``), and a
150
- predefined integer for memory management actions should be used . The supported
151
- numbers and their meanings are as below.
163
+ Action
164
+ ~~~~~~
165
+
166
+ The `` <action> `` is a predefined integer for memory management actions, which
167
+ DAMON will apply to the regions having the target access pattern . The
168
+ supported numbers and their meanings are as below.
152
169
153
170
- 0: Call ``madvise() `` for the region with ``MADV_WILLNEED ``
154
171
- 1: Call ``madvise() `` for the region with ``MADV_COLD ``
@@ -157,20 +174,82 @@ numbers and their meanings are as below.
157
174
- 4: Call ``madvise() `` for the region with ``MADV_NOHUGEPAGE ``
158
175
- 5: Do nothing but count the statistics
159
176
160
- You can disable schemes by simply writing an empty string to the file. For
161
- example, below commands applies a scheme saying "If a memory region of size in
162
- [4KiB, 8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate
163
- interval in [10, 20], page out the region", check the entered scheme again, and
164
- finally remove the scheme. ::
177
+ Quota
178
+ ~~~~~
165
179
166
- # cd <debugfs>/damon
167
- # echo "4096 8192 0 5 10 20 2" > schemes
168
- # cat schemes
169
- 4096 8192 0 5 10 20 2 0 0
170
- # echo > schemes
180
+ Optimal ``target access pattern `` for each ``action `` is workload dependent, so
181
+ not easy to find. Worse yet, setting a scheme of some action too aggressive
182
+ can cause severe overhead. To avoid such overhead, users can limit time and
183
+ size quota for the scheme via the ``<quota> `` in below form::
184
+
185
+ <ms> <sz> <reset interval> <priority weights>
186
+
187
+ This makes DAMON to try to use only up to ``<ms> `` milliseconds for applying
188
+ the action to memory regions of the ``target access pattern `` within the
189
+ ``<reset interval> `` milliseconds, and to apply the action to only up to
190
+ ``<sz> `` bytes of memory regions within the ``<reset interval> ``. Setting both
191
+ ``<ms> `` and ``<sz> `` zero disables the quota limits.
192
+
193
+ When the quota limit is expected to be exceeded, DAMON prioritizes found memory
194
+ regions of the ``target access pattern `` based on their size, access frequency,
195
+ and age. For personalized prioritization, users can set the weights for the
196
+ three properties in ``<priority weights> `` in below form::
197
+
198
+ <size weight> <access frequency weight> <age weight>
199
+
200
+ Watermarks
201
+ ~~~~~~~~~~
202
+
203
+ Some schemes would need to run based on current value of the system's specific
204
+ metrics like free memory ratio. For such cases, users can specify watermarks
205
+ for the condition.::
206
+
207
+ <metric> <check interval> <high mark> <middle mark> <low mark>
208
+
209
+ ``<metric> `` is a predefined integer for the metric to be checked. The
210
+ supported numbers and their meanings are as below.
211
+
212
+ - 0: Ignore the watermarks
213
+ - 1: System's free memory rate (per thousand)
214
+
215
+ The value of the metric is checked every ``<check interval> `` microseconds.
216
+
217
+ If the value is higher than ``<high mark> `` or lower than ``<low mark> ``, the
218
+ scheme is deactivated. If the value is lower than ``<mid mark> ``, the scheme
219
+ is activated.
220
+
221
+ .. _damos_stats :
222
+
223
+ Statistics
224
+ ~~~~~~~~~~
225
+
226
+ It also counts the total number and bytes of regions that each scheme is tried
227
+ to be applied, the two numbers for the regions that each scheme is successfully
228
+ applied, and the total number of the quota limit exceeds. This statistics can
229
+ be used for online analysis or tuning of the schemes.
230
+
231
+ The statistics can be shown by reading the ``schemes `` file. Reading the file
232
+ will show each scheme you entered in each line, and the five numbers for the
233
+ statistics will be added at the end of each line.
171
234
172
- The last two integers in the 4th line of above example is the total number and
173
- the total size of the regions that the scheme is applied.
235
+ Example
236
+ ~~~~~~~
237
+
238
+ Below commands applies a scheme saying "If a memory region of size in [4KiB,
239
+ 8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate
240
+ interval in [10, 20], page out the region. For the paging out, use only up to
241
+ 10ms per second, and also don't page out more than 1GiB per second. Under the
242
+ limitation, page out memory regions having longer age first. Also, check the
243
+ free memory rate of the system every 5 seconds, start the monitoring and paging
244
+ out when the free memory rate becomes lower than 50%, but stop it if the free
245
+ memory rate becomes larger than 60%, or lower than 30%".::
246
+
247
+ # cd <debugfs>/damon
248
+ # scheme="4096 8192 0 5 10 20 2" # target access pattern and action
249
+ # scheme+=" 10 $((1024*1024*1024)) 1000" # quotas
250
+ # scheme+=" 0 0 100" # prioritization weights
251
+ # scheme+=" 1 5000000 600 500 300" # watermarks
252
+ # echo "$scheme" > schemes
174
253
175
254
176
255
Turning On/Off
@@ -195,6 +274,54 @@ the monitoring is turned on. If you write to the files while DAMON is running,
195
274
an error code such as ``-EBUSY `` will be returned.
196
275
197
276
277
+ Monitoring Thread PID
278
+ ---------------------
279
+
280
+ DAMON does requested monitoring with a kernel thread called ``kdamond ``. You
281
+ can get the pid of the thread by reading the ``kdamond_pid `` file. When the
282
+ monitoring is turned off, reading the file returns ``none ``. ::
283
+
284
+ # cd <debugfs>/damon
285
+ # cat monitor_on
286
+ off
287
+ # cat kdamond_pid
288
+ none
289
+ # echo on > monitor_on
290
+ # cat kdamond_pid
291
+ 18594
292
+
293
+
294
+ Using Multiple Monitoring Threads
295
+ ---------------------------------
296
+
297
+ One ``kdamond `` thread is created for each monitoring context. You can create
298
+ and remove monitoring contexts for multiple ``kdamond `` required use case using
299
+ the ``mk_contexts `` and ``rm_contexts `` files.
300
+
301
+ Writing the name of the new context to the ``mk_contexts `` file creates a
302
+ directory of the name on the DAMON debugfs directory. The directory will have
303
+ DAMON debugfs files for the context. ::
304
+
305
+ # cd <debugfs>/damon
306
+ # ls foo
307
+ # ls: cannot access 'foo': No such file or directory
308
+ # echo foo > mk_contexts
309
+ # ls foo
310
+ # attrs init_regions kdamond_pid schemes target_ids
311
+
312
+ If the context is not needed anymore, you can remove it and the corresponding
313
+ directory by putting the name of the context to the ``rm_contexts `` file. ::
314
+
315
+ # echo foo > rm_contexts
316
+ # ls foo
317
+ # ls: cannot access 'foo': No such file or directory
318
+
319
+ Note that ``mk_contexts ``, ``rm_contexts ``, and ``monitor_on `` files are in the
320
+ root directory only.
321
+
322
+
323
+ .. _tracepoint :
324
+
198
325
Tracepoint for Monitoring Results
199
326
=================================
200
327
0 commit comments