@@ -131,24 +131,38 @@ Schemes
131
131
132
132
For usual DAMON-based data access aware memory management optimizations, users
133
133
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.
134
+ region of a specific access pattern. DAMON receives such formalized operation
135
+ schemes from the user and applies those to the target processes.
139
136
140
137
Users can get and set the schemes by reading from and writing to ``schemes ``
141
138
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:
139
+ the file, each of the schemes should be represented in each line in below
140
+ form::
143
141
144
- min-size max-size min-acc max-acc min-age max-age action
142
+ <target access pattern> <action> <quota> <watermarks>
145
143
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.
144
+ You can disable schemes by simply writing an empty string to the file.
145
+
146
+ Target Access Pattern
147
+ ~~~~~~~~~~~~~~~~~~~~~
148
+
149
+ The ``<target access pattern> `` is constructed with three ranges in below
150
+ form::
151
+
152
+ min-size max-size min-acc max-acc min-age max-age
153
+
154
+ Specifically, bytes for the size of regions (``min-size `` and ``max-size ``),
155
+ number of monitored accesses per aggregate interval for access frequency
156
+ (``min-acc `` and ``max-acc ``), number of aggregate intervals for the age of
157
+ regions (``min-age `` and ``max-age ``) are specified. Note that the ranges are
158
+ closed interval.
159
+
160
+ Action
161
+ ~~~~~~
162
+
163
+ The ``<action> `` is a predefined integer for memory management actions, which
164
+ DAMON will apply to the regions having the target access pattern. The
165
+ supported numbers and their meanings are as below.
152
166
153
167
- 0: Call ``madvise() `` for the region with ``MADV_WILLNEED ``
154
168
- 1: Call ``madvise() `` for the region with ``MADV_COLD ``
@@ -157,20 +171,79 @@ numbers and their meanings are as below.
157
171
- 4: Call ``madvise() `` for the region with ``MADV_NOHUGEPAGE ``
158
172
- 5: Do nothing but count the statistics
159
173
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. ::
174
+ Quota
175
+ ~~~~~
165
176
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
177
+ Optimal ``target access pattern `` for each ``action `` is workload dependent, so
178
+ not easy to find. Worse yet, setting a scheme of some action too aggressive
179
+ can cause severe overhead. To avoid such overhead, users can limit time and
180
+ size quota for the scheme via the ``<quota> `` in below form::
181
+
182
+ <ms> <sz> <reset interval> <priority weights>
183
+
184
+ This makes DAMON to try to use only up to ``<ms> `` milliseconds for applying
185
+ the action to memory regions of the ``target access pattern `` within the
186
+ ``<reset interval> `` milliseconds, and to apply the action to only up to
187
+ ``<sz> `` bytes of memory regions within the ``<reset interval> ``. Setting both
188
+ ``<ms> `` and ``<sz> `` zero disables the quota limits.
189
+
190
+ When the quota limit is expected to be exceeded, DAMON prioritizes found memory
191
+ regions of the ``target access pattern `` based on their size, access frequency,
192
+ and age. For personalized prioritization, users can set the weights for the
193
+ three properties in ``<priority weights> `` in below form::
194
+
195
+ <size weight> <access frequency weight> <age weight>
196
+
197
+ Watermarks
198
+ ~~~~~~~~~~
171
199
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.
200
+ Some schemes would need to run based on current value of the system's specific
201
+ metrics like free memory ratio. For such cases, users can specify watermarks
202
+ for the condition.::
203
+
204
+ <metric> <check interval> <high mark> <middle mark> <low mark>
205
+
206
+ ``<metric> `` is a predefined integer for the metric to be checked. The
207
+ supported numbers and their meanings are as below.
208
+
209
+ - 0: Ignore the watermarks
210
+ - 1: System's free memory rate (per thousand)
211
+
212
+ The value of the metric is checked every ``<check interval> `` microseconds.
213
+
214
+ If the value is higher than ``<high mark> `` or lower than ``<low mark> ``, the
215
+ scheme is deactivated. If the value is lower than ``<mid mark> ``, the scheme
216
+ is activated.
217
+
218
+ Statistics
219
+ ~~~~~~~~~~
220
+
221
+ It also counts the total number and bytes of regions that each scheme is
222
+ applied. This statistics can be used for online analysis or tuning of the
223
+ schemes.
224
+
225
+ The statistics can be shown by reading the ``schemes `` file. Reading the file
226
+ will show each scheme you entered in each line, and the two numbers for the
227
+ statistics will be added at the end of each line.
228
+
229
+ Example
230
+ ~~~~~~~
231
+
232
+ Below commands applies a scheme saying "If a memory region of size in [4KiB,
233
+ 8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate
234
+ interval in [10, 20], page out the region. For the paging out, use only up to
235
+ 10ms per second, and also don't page out more than 1GiB per second. Under the
236
+ limitation, page out memory regions having longer age first. Also, check the
237
+ free memory rate of the system every 5 seconds, start the monitoring and paging
238
+ out when the free memory rate becomes lower than 50%, but stop it if the free
239
+ memory rate becomes larger than 60%, or lower than 30%".::
240
+
241
+ # cd <debugfs>/damon
242
+ # scheme="4096 8192 0 5 10 20 2" # target access pattern and action
243
+ # scheme+=" 10 $((1024*1024*1024)) 1000" # quotas
244
+ # scheme+=" 0 0 100" # prioritization weights
245
+ # scheme+=" 1 5000000 600 500 300" # watermarks
246
+ # echo "$scheme" > schemes
174
247
175
248
176
249
Turning On/Off
0 commit comments