... | ... | ||
---|---|---|---|
56 | repeatable tries, it can be a good job for machines. | 56 | repeatable tries, it can be a good job for machines. |
57 | 57 | ||
58 | Based on the guideline's theory, we design an automation of aggregation | 58 | Based on the guideline's theory, we design an automation of aggregation |
59 | interval tuning, in a way similar to that of camera auto-exposure | 59 | interval tuning, in a way similar to that of camera auto-exposure |
60 | feature. It defines the amount of interesting information as the ratio | 60 | feature. It defines the amount of interesting information as the ratio |
61 | of DAMON-observed access events that DAMON actually observed to | 61 | of captured access events to total capturing attempts of single snapshot, |
62 | theoretical maximum amount of it within each snapshot. Events are | 62 | or more technically speaking, the ratio of positive access check samples |
63 | accounted in byte and sampling attempts granularity. For example, let's | 63 | to total samples within the aggregation interval. It allows the users |
64 | say there is a region of 'X' bytes size. DAMON tried access check | 64 | to set the target value of the ratio. Once the target is set, the |
65 | smapling for the region 'Y' times in total for a given aggregation. | 65 | automation periodically measures the current value of the ratio and |
66 | Among the 'Y' attempts, 'Z' times it shown positive results. Then, the | 66 | increase or decrease the aggregation interval if the ratio value is |
67 | theoritical maximum number of access events for the region is 'X * Y'. | 67 | lower or higher than the target. The amount of the change is proportion |
68 | And the number of access events that DAMON has observed for the region | 68 | to the distance between current value and the target value. |
69 | is 'X * Z'. The abount of the interesting information is | ||
70 | '(X * Z / X * Y)'. Note that each snapshot would have multiple regions. | ||
71 | 69 | ||
72 | Users can set an arbitrary value of the ratio as their target. Once the | 70 | To avoid auto-tuning goes too long way, let users set minimum and |
73 | target is set, the automation periodically measures the current value of | 71 | maximum aggregation interval time. Changing only aggregation interval |
74 | the ratio and increase or decrease the aggregation interval if the ratio | 72 | while sampling interval is kept make the maximum level of access |
75 | value is lower or higher than the target. The amount of the change is | 73 | frequency in each snapshot, or discernment of regions inconsistent. |
76 | proportion to the distance between the current adn the target values. | 74 | Also, unnecessarily short sampling interval causes meaningless |
77 | 75 | monitoring overhed. The automation therefore adjusts the sampling | |
78 | To avoid auto-tuning goes too long way, let users set the minimum and | 76 | interval together with aggregation interval, while keeping the ratio |
79 | the maximum aggregation interval times. Changing only aggregation | 77 | between the two intervals. Users can set the ratio, or the discernment. |
80 | interval while sampling interval is kept makes the maximum level of | ||
81 | access frequency in each snapshot, or discernment of regions | ||
82 | inconsistent. Also, unnecessarily short sampling interval causes | ||
83 | meaningless monitoring overhed. The automation therefore adjusts the | ||
84 | sampling interval together with aggregation interval, while keeping the | ||
85 | ratio between the two intervals. Users can set the ratio, or the | ||
86 | discernment. | ||
87 | 78 | ||
88 | Discussion | 79 | Discussion |
89 | ========== | 80 | ========== |
90 | 81 | ||
91 | The modified question (aimed amount of access events, or lights, in each | 82 | The modified question (aimed amount of heats in each snapshot) is easy |
92 | snapshot) is easy to answer by both the users and the kernel. If users | 83 | to answer by both the users and the kernel. If users are interested in |
93 | are interested in finding more cold regions, the value should be lower, | 84 | finding more cold regions, the value should be lower, and vice versa. |
94 | and vice versa. If users have no idea, kernel can suggest a fair | 85 | If users have no idea, kernel can suggest about 20% positive access |
95 | default value based on some theories and experiments. For example, | 86 | samples ratio as a fair default value based on the Pareto principle. |
96 | based on the Pareto principle (80/20 rule), we could expect 20% target | ||
97 | ratio will capture 80% of real access events. Since 80% might be too | ||
98 | high, applying the rule once again, 4% (20% * 20%) may capture about 56% | ||
99 | (80% * 80%) of real access events. | ||
100 | 87 | ||
101 | Sampling to aggregation intervals ratio and min/max aggregation | 88 | Sampling to aggregation intervals ratio and min/max aggregation |
102 | intervals are also arguably easy to answer. What users want is | 89 | intervals are also arguably easy to answer. What users want is |
103 | discernment of regions for efficient system operation, for examples, X | 90 | discernment of regions for efficient system operation, for examples, X |
104 | amount of colder regions or Y amount of warmer regions, not exactly how | 91 | amount of colder regions or Y amount of warmer regions, not exactly how |
105 | many times each cache line is accessed in nanoseconds degree. The | 92 | many times each cache line is accessed in nanoseconds degree. The |
106 | appropriate min/max aggregation interval can relatively naively set, and | 93 | appropriate min/max aggregation interval can relatively naively set, and |
107 | may better to set for aimed monitoring overhead. Since sampling | 94 | may better to set for aimed monitoring overhead. Since sampling |
108 | interval is directly deciding the overhead, setting it based on the | 95 | interval is directly related with the overhead, setting it based on the |
109 | sampling interval can be easy. With my experiences, I'd argue the | 96 | sampling interval can be easy. With my experiences, I'd argue the |
110 | intervals ratio 0.05, and 5 milliseconds to 20 seconds sampling interval | 97 | intervals ratio 0.05, and 5 milliseconds to 20 seconds sampling interval |
111 | range (100 milliseconds to 400 seconds aggregation interval) can be a | 98 | range (100 milliseconds to 400 seconds aggregation interval) can be a |
112 | good default suggestion. | 99 | good default suggestions. |
113 | 100 | ||
114 | Evaluation | 101 | Evaluation |
115 | ========== | 102 | ========== |
116 | 103 | ||
117 | On a machine running a real world server workload, I ran DAMON to | 104 | We confirmed the tuning works as expected with only a few simple |
118 | monitor its physical address space for about 23 hours, with this feature | 105 | workloads including kernel builds, and that's why this is an RFC. We |
119 | turned on. We set it to tune sampling interval in a range from 5 | 106 | will conduct more evaluations with more massive and realistic workloads |
120 | milliseconds to 10 seconds, aiming 4 % DAMON-observed access ratio per | 107 | and share the results by the time that we drop the RFC tag. |
121 | three aggregation intervals. The exact command I used is as below. | ||
122 | |||
123 | damo start --monitoring_intervals_goal 4% 3 5ms 10s --damos_action stat | ||
124 | |||
125 | During the test run, DAMON continuously updated sampling and aggregation | ||
126 | intervals as designed, within the given range. For all the time, DAMON | ||
127 | was able to find the intervals that meets the target access events ratio | ||
128 | in the given intervals range (sampling interval between 5 milliseconds | ||
129 | and 10 seconds). | ||
130 | |||
131 | For most of the time, tuned sampling interval was converged in 300-400 | ||
132 | milliseconds. It made only small amount of changes within the range. | ||
133 | The average of the tuned sampling interval during the test was about 380 | ||
134 | milliseconds. | ||
135 | |||
136 | The workload periodically gets less load and decreases its CPU usage. | ||
137 | Presumably this also caused it making less memory access events. | ||
138 | Reactively to such event,s DAMON also increased the intervals as | ||
139 | expected. It was still able to find the optimum interval that | ||
140 | satisfying the target access ratio within the given intervals range. | ||
141 | Usually it was converged to about 5 seconds. Once the workload gets | ||
142 | normal amount of load again, DAMON reactively reduced the intervals to | ||
143 | the normal range. | ||
144 | |||
145 | I collected and visualized DAMON's monitoring results on the server a | ||
146 | few times. Every time the visualized access pattern looked not biased | ||
147 | to only cold or hot pages but diverse and balanced. Let me show some of | ||
148 | the snapshots that I collected at the nearly end of the test (after | ||
149 | about 23 hours have passed since starting DAMON on the server). | ||
150 | |||
151 | The recency histogram looks as below. Please note that this | ||
152 | visualization shows only a very coarse grained information. For more | ||
153 | details about the visualization format, please refer to DAMON user-space | ||
154 | tool documentation[1]. | ||
155 | |||
156 | # ./damo report access --style recency-sz-hist --tried_regions_of 0 0 0 --access_rate 0 0 | ||
157 | <last accessed time (us)> <total size> | ||
158 | [-19 h 7 m 45.514 s, -17 h 12 m 58.963 s) 6.198 GiB |**** | | ||
159 | [-17 h 12 m 58.963 s, -15 h 18 m 12.412 s) 0 B | | | ||
160 | [-15 h 18 m 12.412 s, -13 h 23 m 25.860 s) 0 B | | | ||
161 | [-13 h 23 m 25.860 s, -11 h 28 m 39.309 s) 0 B | | | ||
162 | [-11 h 28 m 39.309 s, -9 h 33 m 52.757 s) 0 B | | | ||
163 | [-9 h 33 m 52.757 s, -7 h 39 m 6.206 s) 0 B | | | ||
164 | [-7 h 39 m 6.206 s, -5 h 44 m 19.654 s) 0 B | | | ||
165 | [-5 h 44 m 19.654 s, -3 h 49 m 33.103 s) 0 B | | | ||
166 | [-3 h 49 m 33.103 s, -1 h 54 m 46.551 s) 0 B | | | ||
167 | [-1 h 54 m 46.551 s, -0 ns) 16.967 GiB |********* | | ||
168 | [-0 ns, --6886551440000 ns) 38.835 GiB |********************| | ||
169 | memory bw estimate: 9.425 GiB per second | ||
170 | total size: 62.000 GiB | ||
171 | |||
172 | It shows about 38 GiB of memory was accessed at least once within last | ||
173 | aggregation interval (given ~300 milliseconds tuned sampling interval, | ||
174 | this is about six seconds). This is about 61 % of the total memory. In | ||
175 | other words, DAMON found warmest 61 % memory of the system. The number | ||
176 | is particularly interesting given our Pareto principle based theory for | ||
177 | the tuning goal value. We set it as 20 % of 20 % (4 %), thinking it | ||
178 | would capture 80 % of 80 % (64 %) real access events. And it foudn 61 % | ||
179 | hot memory, or working set. Nevertheless, to make the theory clearer, | ||
180 | much more discussion and tests would be needed. At the moment, | ||
181 | nonetheless, we can say making the target value higher helps finding | ||
182 | more hot memory regions. | ||
183 | |||
184 | The histogram also shows an amount of cold memory. About 17 GiB memory | ||
185 | of the system has not accessed at least for last aggregation interval | ||
186 | (about six seconds), and at most for about last two hours. The real | ||
187 | longest unaccessed time of the 17 GiB memory was about 19 minutes, | ||
188 | though. This is a limitation of this visualization format. | ||
189 | |||
190 | It further found very cold 6 GiB memory. It has not accessed at least for last | ||
191 | 17 hours and at most 19 hours. | ||
192 | |||
193 | What about hot memory distribution? To see this, I capture and | ||
194 | visualize the snapshot in access temperature histogram. Again, please | ||
195 | refer to the DAMON user-space tool documentation[1] for the format and | ||
196 | what access temperature mean. Both the visualization and metric shows | ||
197 | only very coarse grained and limited information. The resulting | ||
198 | histogram look like below. | ||
199 | |||
200 | # ./damo report access --style temperature-sz-hist --tried_regions_of 0 0 0 | ||
201 | <temperature> <total size> | ||
202 | [-6,840,763,776,000, -5,501,580,939,800) 6.198 GiB |*** | | ||
203 | [-5,501,580,939,800, -4,162,398,103,600) 0 B | | | ||
204 | [-4,162,398,103,600, -2,823,215,267,400) 0 B | | | ||
205 | [-2,823,215,267,400, -1,484,032,431,200) 0 B | | | ||
206 | [-1,484,032,431,200, -144,849,595,000) 0 B | | | ||
207 | [-144,849,595,000, 1,194,333,241,200) 55.802 GiB |********************| | ||
208 | [1,194,333,241,200, 2,533,516,077,400) 4.000 KiB |* | | ||
209 | [2,533,516,077,400, 3,872,698,913,600) 4.000 KiB |* | | ||
210 | [3,872,698,913,600, 5,211,881,749,800) 8.000 KiB |* | | ||
211 | [5,211,881,749,800, 6,551,064,586,000) 12.000 KiB |* | | ||
212 | [6,551,064,586,000, 7,890,247,422,200) 4.000 KiB |* | | ||
213 | memory bw estimate: 5.178 GiB per second | ||
214 | total size: 62.000 GiB | ||
215 | |||
216 | We can see most of the memory is in similar access temperature range, | ||
217 | and definitely some pages are extremely hot. | ||
218 | |||
219 | To see the picture in more detail, let's capture and visualize the | ||
220 | snapshot per DAMON-region, sorted by their access temperature. The | ||
221 | total number of the regions was about 300. Due to the limited space, | ||
222 | I'm showing only a few parts of the output here. | ||
223 | |||
224 | # ./damo report access --style hot --tried_regions_of 0 0 0 | ||
225 | heatmap: 00000000888888889999999888888888888888888888888888888888888888888888888888888888 | ||
226 | # min/max temperatures: -6,827,258,184,000, 17,589,052,500, column size: 793.600 MiB | ||
227 | |999999999999999999999999999999999999999| 4.000 KiB access 100 % 18 h 9 m 43.918 s | ||
228 | |999999999999999999999999999999999999999| 8.000 KiB access 100 % 17 h 56 m 5.351 s | ||
229 | |999999999999999999999999999999999999999| 4.000 KiB access 100 % 15 h 24 m 19.634 s | ||
230 | |999999999999999999999999999999999999999| 4.000 KiB access 100 % 14 h 10 m 55.606 s | ||
231 | |999999999999999999999999999999999999999| 4.000 KiB access 100 % 11 h 34 m 18.993 s | ||
232 | [...] | ||
233 | |99999999999999999999999999999| 8.000 KiB access 100 % 1 m 27.945 s | ||
234 | |11111111111111111111111111111| 80.000 KiB access 15 % 1 m 21.180 s | ||
235 | |00000000000000000000000000000| 24.000 KiB access 5 % 1 m 21.180 s | ||
236 | |00000000000000000000000000000| 5.919 GiB access 10 % 1 m 14.415 s | ||
237 | |99999999999999999999999999999| 12.000 KiB access 100 % 1 m 7.650 s | ||
238 | [...] | ||
239 | |0| 4.000 KiB access 5 % 0 ns | ||
240 | |0| 12.000 KiB access 5 % 0 ns | ||
241 | |0| 188.000 KiB access 0 % 0 ns | ||
242 | |0| 24.000 KiB access 0 % 0 ns | ||
243 | |0| 48.000 KiB access 0 % 0 ns | ||
244 | [...] | ||
245 | |0000000000000000000000000000000| 8.000 KiB access 0 % 6 m 45.901 s | ||
246 | |00000000000000000000000000000000| 36.000 KiB access 0 % 7 m 26.491 s | ||
247 | |00000000000000000000000000000000| 4.000 KiB access 0 % 12 m 37.682 s | ||
248 | |000000000000000000000000000000000| 8.000 KiB access 0 % 18 m 9.168 s | ||
249 | |000000000000000000000000000000000| 16.000 KiB access 0 % 19 m 3.288 s | ||
250 | |0000000000000000000000000000000000000000| 6.198 GiB access 0 % 18 h 57 m 52.582 s | ||
251 | memory bw estimate: 8.798 GiB per second | ||
252 | total size: 62.000 GiB | ||
253 | |||
254 | We can see DAMON found small and extremely hot regions that accessed for | ||
255 | all access check sampling (once per about 300 milliseconds) for more | ||
256 | than 10 hours. The access temperature rapidly decreases. DAMON was | ||
257 | also able to find small and big regions that not accessed for up to | ||
258 | about 19 minutes. It even found an outlier cold region of 6 GiB that | ||
259 | not accessed for about 19 hours. It is unclear what the outlier region | ||
260 | is, as of this writing. | ||
261 | |||
262 | For the testing, DAMON was consuming about 0.1% of single CPU time. | ||
263 | This is again expected results, since DAMON was using about 370 | ||
264 | milliseconds sampling interval in most case. | ||
265 | |||
266 | # ps -p $kdamond_pid -o %cpu | ||
267 | %CPU | ||
268 | 0.1 | ||
269 | |||
270 | I also ran similar tests against kernel build workload and an in-memory | ||
271 | cache workload benchmark[2]. Detialed results including tuned intervals | ||
272 | and captured access pattern were of course different sicne those depend | ||
273 | on the workloads. But the auto-tuning feature was always working as | ||
274 | expected like the above results for the real world workload. | ||
275 | |||
276 | To wrap up, with intervals auto-tuning feature, DAMON was able to | ||
277 | capture access pattern snapshots of a quality on a real world server | ||
278 | workload. The auto-tuning feature was able to adaptively react to the | ||
279 | dynamic access patterns of the workload and reliably provide consistent | ||
280 | monitoring results without manual human interventions. Also, the | ||
281 | auto-tuning made DAMON consumes only necessary amount of resource for | ||
282 | the required quality. | ||
283 | |||
284 | Changelog | ||
285 | ========= | ||
286 | |||
287 | Changes from RFC v2 | ||
288 | (https://lore.kernel.org/20250228220328.49438-1-sj@kernel.org) | ||
289 | - Add detailed evaluation results on cover letter | ||
290 | |||
291 | Changes from RFC v1 | ||
292 | (https://lore.kernel.org/20250213014438.145611-1-sj@kernel.org) | ||
293 | - Replace the target metric from positive samples ratio to | ||
294 | DAMON-observed access samples ratio | ||
295 | - Fix wrong max events accounting bug | ||
296 | - Fix double-increase of next_aggregation_sis | ||
297 | |||
298 | References | ||
299 | ========== | ||
300 | |||
301 | [1] https://github.com/damonitor/damo/blob/next/USAGE.md#access-report-styles | ||
302 | [2] https://github.com/facebookresearch/DCPerf/blob/main/packages/tao_bench/README.md | ||
303 | 108 | ||
304 | SeongJae Park (8): | 109 | SeongJae Park (8): |
305 | mm/damon: add data structure for monitoring intervals auto-tuning | 110 | mm/damon: add data structure for monitoring intervals auto-tuning |
306 | mm/damon/core: implement intervals auto-tuning | 111 | mm/damon/core: implement intervals auto-tuning |
307 | mm/damon/sysfs: implement intervals tuning goal directory | 112 | mm/damon/sysfs: implement intervals tuning goal directory |
... | ... | ||
313 | Docs/admin-guide/mm/damon/usage: add intervals_goal directory on the | 118 | Docs/admin-guide/mm/damon/usage: add intervals_goal directory on the |
314 | hierarchy | 119 | hierarchy |
315 | 120 | ||
316 | .../ABI/testing/sysfs-kernel-mm-damon | 30 +++ | 121 | .../ABI/testing/sysfs-kernel-mm-damon | 30 +++ |
317 | Documentation/admin-guide/mm/damon/usage.rst | 25 ++ | 122 | Documentation/admin-guide/mm/damon/usage.rst | 25 ++ |
318 | Documentation/mm/damon/design.rst | 50 ++++ | 123 | Documentation/mm/damon/design.rst | 38 +++ |
319 | include/linux/damon.h | 43 ++++ | 124 | include/linux/damon.h | 43 ++++ |
320 | mm/damon/core.c | 98 ++++++++ | 125 | mm/damon/core.c | 90 ++++++++ |
321 | mm/damon/sysfs.c | 216 ++++++++++++++++++ | 126 | mm/damon/sysfs.c | 216 ++++++++++++++++++ |
322 | 6 files changed, 462 insertions(+) | 127 | 6 files changed, 442 insertions(+) |
323 | 128 | ||
324 | 129 | ||
325 | base-commit: 2ade695ab17eb4005f006001aa9c51ad22d2f206 | 130 | base-commit: d5c35650f4945e1406871f9d9d51ab8c54ec0d03 |
326 | -- | 131 | -- |
327 | 2.39.5 | 132 | 2.39.5 | diff view generated by jsdifflib |
1 | Add data structures for DAMON sampling and aggregation intervals | 1 | Add data structures for using DAMON sampling and aggregation intervals |
---|---|---|---|
2 | automatic tuning that aims specific amount of DAMON-observed access | 2 | automatic tuning aiming specific amount of access events per snapshot. |
3 | events per snapshot. In more detail, define the data structure for the | 3 | Specificaslly, define a data structure to define the tuning goal, namely |
4 | tuning goal, link it to the monitoring attributes data structure so that | 4 | target ratio of positive access check samples, link it to monitoring |
5 | DAMON kernel API callers can make the request, and update parameters | 5 | attributes data structure so that DAMON kernel API users can make the |
6 | setup DAMON function to respect the new parameter. | 6 | request, and update parameters setup DAMON function to respect the new |
7 | data. | ||
7 | 8 | ||
8 | Signed-off-by: SeongJae Park <sj@kernel.org> | 9 | Signed-off-by: SeongJae Park <sj@kernel.org> |
9 | --- | 10 | --- |
10 | include/linux/damon.h | 27 +++++++++++++++++++++++++++ | 11 | include/linux/damon.h | 27 +++++++++++++++++++++++++++ |
11 | mm/damon/core.c | 22 ++++++++++++++++++++++ | 12 | mm/damon/core.c | 22 ++++++++++++++++++++++ |
... | ... | ||
20 | }; | 21 | }; |
21 | 22 | ||
22 | +/** | 23 | +/** |
23 | + * struct damon_intervals_goal - Monitoring intervals auto-tuning goal. | 24 | + * struct damon_intervals_goal - Monitoring intervals auto-tuning goal. |
24 | + * | 25 | + * |
25 | + * @access_bp: Access events observation ratio to achieve in bp. | 26 | + * @samples_bp: Positive access check samples ratio to achieve. |
26 | + * @aggrs: Number of aggregations to acheive @access_bp within. | 27 | + * @aggrs: Number of aggregations to acheive @samples_bp within. |
27 | + * @min_sample_us: Minimum resulting sampling interval in microseconds. | 28 | + * @min_sample_us: Minimum resulting sampling interval in microseconds. |
28 | + * @max_sample_us: Maximum resulting sampling interval in microseconds. | 29 | + * @max_sample_us: Maximum resulting sampling interval in microseconds. |
29 | + * | 30 | + * |
30 | + * DAMON automatically tunes &damon_attrs->sample_interval and | 31 | + * DAMON automatically tunes &damon_attrs->sample_interval and |
31 | + * &damon_attrs->aggr_interval aiming the ratio in bp (1/10,000) of | 32 | + * &damon_attrs->aggr_interval aiming the ratio in bp (1/10,000) of access |
32 | + * DAMON-observed access events to theoretical maximum amount within @aggrs | 33 | + * check samples that shown positive result (was accessed) to total samples |
33 | + * aggregations be same to @access_bp. The logic increases | 34 | + * within @aggrs aggregations be same to @samples_bp. The logic increases |
34 | + * &damon_attrs->aggr_interval and &damon_attrs->sampling_interval in same | 35 | + * &damon_attrs->aggr_interval and &damon_attrs->sampling_interval in same |
35 | + * ratio if the current access events observation ratio is lower than the | 36 | + * ratio if the current positive access samples ratio is lower than the target |
36 | + * target for each @aggrs aggregations, and vice versa. | 37 | + * for each @aggrs aggregations, and vice versa. |
37 | + * | 38 | + * |
38 | + * If @aggrs is zero, the tuning is disabled and hence this struct is ignored. | 39 | + * If @aggrs is zero, the tuning is disabled and hence this struct is ignored. |
39 | + */ | 40 | + */ |
40 | +struct damon_intervals_goal { | 41 | +struct damon_intervals_goal { |
41 | + unsigned long access_bp; | 42 | + unsigned long samples_bp; |
42 | + unsigned long aggrs; | 43 | + unsigned long aggrs; |
43 | + unsigned long min_sample_us; | 44 | + unsigned long min_sample_us; |
44 | + unsigned long max_sample_us; | 45 | + unsigned long max_sample_us; |
45 | +}; | 46 | +}; |
46 | + | 47 | + |
... | ... | diff view generated by jsdifflib |
1 | Implement the DAMON sampling and aggregation intervals auto-tuning | 1 | Implement the DAMON sampling and aggregation intervals auto-tuning |
---|---|---|---|
2 | mechanism as briefly described on 'struct damon_intervals_goal'. The | 2 | mechanism as designed on the cover letter of this patch series. The |
3 | core part for deciding the direction and amount of the changes is | 3 | mechanism reuses the feedback loop function for DAMOS quotas |
4 | implemented reusing the feedback loop function which is being used for | 4 | auto-tuning. Unlike the DAMOS quotas auto-tuning use case, limit the |
5 | DAMOS quotas auto-tuning. Unlike the DAMOS quotas auto-tuning use case, | 5 | maximum decreasing amount after the adjustment to 50% of the current |
6 | limit the maximum decreasing amount after the adjustment to 50% of the | 6 | value. This is because the intervals have no good merits at rapidly |
7 | current value, though. This is because the intervals have no good | 7 | reducing, and it is assumed the user will set the range of tunable |
8 | merits at rapid reductions since it could unnecessarily increase the | 8 | values not very wide. |
9 | monitoring overhead. | ||
10 | 9 | ||
11 | Signed-off-by: SeongJae Park <sj@kernel.org> | 10 | Signed-off-by: SeongJae Park <sj@kernel.org> |
12 | --- | 11 | --- |
13 | include/linux/damon.h | 16 +++++++++ | 12 | include/linux/damon.h | 16 ++++++++++ |
14 | mm/damon/core.c | 76 +++++++++++++++++++++++++++++++++++++++++++ | 13 | mm/damon/core.c | 68 +++++++++++++++++++++++++++++++++++++++++++ |
15 | 2 files changed, 92 insertions(+) | 14 | 2 files changed, 84 insertions(+) |
16 | 15 | ||
17 | diff --git a/include/linux/damon.h b/include/linux/damon.h | 16 | diff --git a/include/linux/damon.h b/include/linux/damon.h |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/linux/damon.h | 18 | --- a/include/linux/damon.h |
20 | +++ b/include/linux/damon.h | 19 | +++ b/include/linux/damon.h |
... | ... | ||
65 | ctx->next_ops_update_sis = ctx->passed_sample_intervals + | 64 | ctx->next_ops_update_sis = ctx->passed_sample_intervals + |
66 | @@ -XXX,XX +XXX,XX @@ static void kdamond_reset_aggregated(struct damon_ctx *c) | 65 | @@ -XXX,XX +XXX,XX @@ static void kdamond_reset_aggregated(struct damon_ctx *c) |
67 | } | 66 | } |
68 | } | 67 | } |
69 | 68 | ||
70 | +static unsigned long damon_get_intervals_score(struct damon_ctx *c) | ||
71 | +{ | ||
72 | + struct damon_target *t; | ||
73 | + struct damon_region *r; | ||
74 | + unsigned long sz_region, max_access_events = 0, access_events = 0; | ||
75 | + unsigned long target_access_events; | ||
76 | + unsigned long goal_bp = c->attrs.intervals_goal.access_bp; | ||
77 | + | ||
78 | + damon_for_each_target(t, c) { | ||
79 | + damon_for_each_region(r, t) { | ||
80 | + sz_region = damon_sz_region(r); | ||
81 | + max_access_events += sz_region * c->attrs.aggr_samples; | ||
82 | + access_events += sz_region * r->nr_accesses; | ||
83 | + } | ||
84 | + } | ||
85 | + target_access_events = max_access_events * goal_bp / 10000; | ||
86 | + return access_events * 10000 / target_access_events; | ||
87 | +} | ||
88 | + | ||
89 | +static unsigned long damon_feed_loop_next_input(unsigned long last_input, | 69 | +static unsigned long damon_feed_loop_next_input(unsigned long last_input, |
90 | + unsigned long score); | 70 | + unsigned long score); |
91 | + | 71 | + |
92 | +static unsigned long damon_get_intervals_adaptation_bp(struct damon_ctx *c) | 72 | +static unsigned long damon_get_intervals_adaptation_bp(struct damon_ctx *c) |
93 | +{ | 73 | +{ |
94 | + unsigned long score_bp, adaptation_bp; | 74 | + struct damon_target *t; |
75 | + struct damon_region *r; | ||
76 | + unsigned long nr_regions = 0, access_samples = 0; | ||
77 | + struct damon_intervals_goal *goal = &c->attrs.intervals_goal; | ||
78 | + unsigned long max_samples, target_samples, score_bp; | ||
79 | + unsigned long adaptation_bp; | ||
95 | + | 80 | + |
96 | + score_bp = damon_get_intervals_score(c); | 81 | + damon_for_each_target(t, c) { |
82 | + nr_regions = damon_nr_regions(t); | ||
83 | + damon_for_each_region(r, t) | ||
84 | + access_samples += r->nr_accesses; | ||
85 | + } | ||
86 | + max_samples = nr_regions * c->attrs.aggr_samples; | ||
87 | + target_samples = max_samples * goal->samples_bp / 10000; | ||
88 | + score_bp = access_samples * 10000 / target_samples; | ||
97 | + adaptation_bp = damon_feed_loop_next_input(100000000, score_bp) / | 89 | + adaptation_bp = damon_feed_loop_next_input(100000000, score_bp) / |
98 | + 10000; | 90 | + 10000; |
99 | + /* | 91 | + /* |
100 | + * adaptaion_bp ranges from 1 to 20,000. Avoid too rapid reduction of | 92 | + * adaptaion_bp ranges from 1 to 20,000. Avoid too rapid reduction of |
101 | + * the intervals by rescaling [1,10,000] to [5000, 10,000]. | 93 | + * the intervals by rescaling [1,10,000] to [5000, 10,000]. |
102 | + */ | 94 | + */ |
103 | + if (adaptation_bp <= 10000) | 95 | + if (adaptation_bp <= 10000) |
104 | + adaptation_bp = 5000 + adaptation_bp / 2; | 96 | + adaptation_bp = 5000 + adaptation_bp / 2; |
97 | + | ||
105 | + return adaptation_bp; | 98 | + return adaptation_bp; |
106 | +} | 99 | +} |
107 | + | 100 | + |
108 | +static void kdamond_tune_intervals(struct damon_ctx *c) | 101 | +static void kdamond_tune_intervals(struct damon_ctx *c) |
109 | +{ | 102 | +{ |
... | ... | ||
115 | + if (adaptation_bp == 10000) | 108 | + if (adaptation_bp == 10000) |
116 | + return; | 109 | + return; |
117 | + | 110 | + |
118 | + new_attrs = c->attrs; | 111 | + new_attrs = c->attrs; |
119 | + goal = &c->attrs.intervals_goal; | 112 | + goal = &c->attrs.intervals_goal; |
120 | + new_attrs.sample_interval = min(goal->max_sample_us, | 113 | + new_attrs.sample_interval = min( |
121 | + c->attrs.sample_interval * adaptation_bp / 10000); | 114 | + c->attrs.sample_interval * adaptation_bp / 10000, |
122 | + new_attrs.sample_interval = max(goal->min_sample_us, | 115 | + goal->max_sample_us); |
123 | + new_attrs.sample_interval); | 116 | + new_attrs.sample_interval = max(new_attrs.sample_interval, |
117 | + goal->min_sample_us); | ||
124 | + new_attrs.aggr_interval = new_attrs.sample_interval * | 118 | + new_attrs.aggr_interval = new_attrs.sample_interval * |
125 | + c->attrs.aggr_samples; | 119 | + c->attrs.aggr_samples; |
126 | + damon_set_attrs(c, &new_attrs); | 120 | + damon_set_attrs(c, &new_attrs); |
127 | +} | 121 | +} |
128 | + | 122 | + |
... | ... | ||
137 | + ctx->attrs.intervals_goal.aggrs; | 131 | + ctx->attrs.intervals_goal.aggrs; |
138 | 132 | ||
139 | damon_for_each_scheme(scheme, ctx) { | 133 | damon_for_each_scheme(scheme, ctx) { |
140 | apply_interval = scheme->apply_interval_us ? | 134 | apply_interval = scheme->apply_interval_us ? |
141 | @@ -XXX,XX +XXX,XX @@ static int kdamond_fn(void *data) | 135 | @@ -XXX,XX +XXX,XX @@ static int kdamond_fn(void *data) |
142 | sample_interval = ctx->attrs.sample_interval ? | ||
143 | ctx->attrs.sample_interval : 1; | ||
144 | if (ctx->passed_sample_intervals >= next_aggregation_sis) { | 136 | if (ctx->passed_sample_intervals >= next_aggregation_sis) { |
137 | ctx->next_aggregation_sis = next_aggregation_sis + | ||
138 | ctx->attrs.aggr_interval / sample_interval; | ||
145 | + if (ctx->attrs.intervals_goal.aggrs && | 139 | + if (ctx->attrs.intervals_goal.aggrs && |
146 | + ctx->passed_sample_intervals >= | 140 | + ctx->passed_sample_intervals >= |
147 | + ctx->next_intervals_tune_sis) { | 141 | + ctx->next_intervals_tune_sis) { |
148 | + ctx->next_intervals_tune_sis += | 142 | + ctx->next_intervals_tune_sis += |
149 | + ctx->attrs.aggr_samples * | 143 | + ctx->attrs.aggr_samples * |
150 | + ctx->attrs.intervals_goal.aggrs; | 144 | + ctx->attrs.intervals_goal.aggrs; |
151 | + kdamond_tune_intervals(ctx); | 145 | + kdamond_tune_intervals(ctx); |
152 | + sample_interval = ctx->attrs.sample_interval ? | ||
153 | + ctx->attrs.sample_interval : 1; | ||
154 | + | ||
155 | + } | 146 | + } |
156 | ctx->next_aggregation_sis = next_aggregation_sis + | 147 | |
157 | ctx->attrs.aggr_interval / sample_interval; | 148 | kdamond_reset_aggregated(ctx); |
158 | 149 | kdamond_split_regions(ctx); | |
159 | -- | 150 | -- |
160 | 2.39.5 | 151 | 2.39.5 | diff view generated by jsdifflib |
1 | Implement DAMON sysfs interface directory and its files for setting | 1 | Implement DAMON sysfs interface directory and its files for setting |
---|---|---|---|
2 | DAMON sampling and aggregation intervals auto-tuning goal. | 2 | DAMON sampling and aggregation intervals auto-tuning goal. Nearly all |
3 | kernel API data structures that newly introduced for this new feature | ||
4 | are directly exposed. | ||
3 | 5 | ||
4 | Signed-off-by: SeongJae Park <sj@kernel.org> | 6 | Signed-off-by: SeongJae Park <sj@kernel.org> |
5 | --- | 7 | --- |
6 | mm/damon/sysfs.c | 189 +++++++++++++++++++++++++++++++++++++++++++++++ | 8 | mm/damon/sysfs.c | 189 +++++++++++++++++++++++++++++++++++++++++++++++ |
7 | 1 file changed, 189 insertions(+) | 9 | 1 file changed, 189 insertions(+) |
... | ... | ||
18 | + * intervals goal directory | 20 | + * intervals goal directory |
19 | + */ | 21 | + */ |
20 | + | 22 | + |
21 | +struct damon_sysfs_intervals_goal { | 23 | +struct damon_sysfs_intervals_goal { |
22 | + struct kobject kobj; | 24 | + struct kobject kobj; |
23 | + unsigned long access_bp; | 25 | + unsigned long samples_bp; |
24 | + unsigned long aggrs; | 26 | + unsigned long aggrs; |
25 | + unsigned long min_sample_us; | 27 | + unsigned long min_sample_us; |
26 | + unsigned long max_sample_us; | 28 | + unsigned long max_sample_us; |
27 | +}; | 29 | +}; |
28 | + | 30 | + |
29 | +static struct damon_sysfs_intervals_goal *damon_sysfs_intervals_goal_alloc( | 31 | +static struct damon_sysfs_intervals_goal *damon_sysfs_intervals_goal_alloc( |
30 | + unsigned long access_bp, unsigned long aggrs, | 32 | + unsigned long samples_bp, unsigned long aggrs, |
31 | + unsigned long min_sample_us, unsigned long max_sample_us) | 33 | + unsigned long min_sample_us, unsigned long max_sample_us) |
32 | +{ | 34 | +{ |
33 | + struct damon_sysfs_intervals_goal *goal = kmalloc(sizeof(*goal), | 35 | + struct damon_sysfs_intervals_goal *goal = kmalloc(sizeof(*goal), |
34 | + GFP_KERNEL); | 36 | + GFP_KERNEL); |
35 | + | 37 | + |
36 | + if (!goal) | 38 | + if (!goal) |
37 | + return NULL; | 39 | + return NULL; |
38 | + | 40 | + |
39 | + goal->kobj = (struct kobject){}; | 41 | + goal->kobj = (struct kobject){}; |
40 | + goal->access_bp = access_bp; | 42 | + goal->samples_bp = samples_bp; |
41 | + goal->aggrs = aggrs; | 43 | + goal->aggrs = aggrs; |
42 | + goal->min_sample_us = min_sample_us; | 44 | + goal->min_sample_us = min_sample_us; |
43 | + goal->max_sample_us = max_sample_us; | 45 | + goal->max_sample_us = max_sample_us; |
44 | + return goal; | 46 | + return goal; |
45 | +} | 47 | +} |
46 | + | 48 | + |
47 | +static ssize_t access_bp_show(struct kobject *kobj, | 49 | +static ssize_t samples_bp_show(struct kobject *kobj, |
48 | + struct kobj_attribute *attr, char *buf) | 50 | + struct kobj_attribute *attr, char *buf) |
49 | +{ | 51 | +{ |
50 | + struct damon_sysfs_intervals_goal *goal = container_of(kobj, | 52 | + struct damon_sysfs_intervals_goal *goal = container_of(kobj, |
51 | + struct damon_sysfs_intervals_goal, kobj); | 53 | + struct damon_sysfs_intervals_goal, kobj); |
52 | + | 54 | + |
53 | + return sysfs_emit(buf, "%lu\n", goal->access_bp); | 55 | + return sysfs_emit(buf, "%lu\n", goal->samples_bp); |
54 | +} | 56 | +} |
55 | + | 57 | + |
56 | +static ssize_t access_bp_store(struct kobject *kobj, | 58 | +static ssize_t samples_bp_store(struct kobject *kobj, |
57 | + struct kobj_attribute *attr, const char *buf, size_t count) | 59 | + struct kobj_attribute *attr, const char *buf, size_t count) |
58 | +{ | 60 | +{ |
59 | + struct damon_sysfs_intervals_goal *goal = container_of(kobj, | 61 | + struct damon_sysfs_intervals_goal *goal = container_of(kobj, |
60 | + struct damon_sysfs_intervals_goal, kobj); | 62 | + struct damon_sysfs_intervals_goal, kobj); |
61 | + unsigned long nr; | 63 | + unsigned long nr; |
62 | + int err = kstrtoul(buf, 0, &nr); | 64 | + int err = kstrtoul(buf, 0, &nr); |
63 | + | 65 | + |
64 | + if (err) | 66 | + if (err) |
65 | + return err; | 67 | + return err; |
66 | + | 68 | + |
67 | + goal->access_bp = nr; | 69 | + goal->samples_bp = nr; |
68 | + return count; | 70 | + return count; |
69 | +} | 71 | +} |
70 | + | 72 | + |
71 | +static ssize_t aggrs_show(struct kobject *kobj, | 73 | +static ssize_t aggrs_show(struct kobject *kobj, |
72 | + struct kobj_attribute *attr, char *buf) | 74 | + struct kobj_attribute *attr, char *buf) |
... | ... | ||
143 | +static void damon_sysfs_intervals_goal_release(struct kobject *kobj) | 145 | +static void damon_sysfs_intervals_goal_release(struct kobject *kobj) |
144 | +{ | 146 | +{ |
145 | + kfree(container_of(kobj, struct damon_sysfs_intervals_goal, kobj)); | 147 | + kfree(container_of(kobj, struct damon_sysfs_intervals_goal, kobj)); |
146 | +} | 148 | +} |
147 | + | 149 | + |
148 | +static struct kobj_attribute damon_sysfs_intervals_goal_access_bp_attr = | 150 | +static struct kobj_attribute damon_sysfs_intervals_goal_samples_bp_attr = |
149 | + __ATTR_RW_MODE(access_bp, 0600); | 151 | + __ATTR_RW_MODE(samples_bp, 0600); |
150 | + | 152 | + |
151 | +static struct kobj_attribute damon_sysfs_intervals_goal_aggrs_attr = | 153 | +static struct kobj_attribute damon_sysfs_intervals_goal_aggrs_attr = |
152 | + __ATTR_RW_MODE(aggrs, 0600); | 154 | + __ATTR_RW_MODE(aggrs, 0600); |
153 | + | 155 | + |
154 | +static struct kobj_attribute damon_sysfs_intervals_goal_min_sample_us_attr = | 156 | +static struct kobj_attribute damon_sysfs_intervals_goal_min_sample_us_attr = |
155 | + __ATTR_RW_MODE(min_sample_us, 0600); | 157 | + __ATTR_RW_MODE(min_sample_us, 0600); |
156 | + | 158 | + |
157 | +static struct kobj_attribute damon_sysfs_intervals_goal_max_sample_us_attr = | 159 | +static struct kobj_attribute damon_sysfs_intervals_goal_max_sample_us_attr = |
158 | + __ATTR_RW_MODE(max_sample_us, 0600); | 160 | + __ATTR_RW_MODE(max_sample_us, 0600); |
159 | + | 161 | + |
160 | +static struct attribute *damon_sysfs_intervals_goal_attrs[] = { | 162 | +static struct attribute *damon_sysfs_intervals_goal_attrs[] = { |
161 | + &damon_sysfs_intervals_goal_access_bp_attr.attr, | 163 | + &damon_sysfs_intervals_goal_samples_bp_attr.attr, |
162 | + &damon_sysfs_intervals_goal_aggrs_attr.attr, | 164 | + &damon_sysfs_intervals_goal_aggrs_attr.attr, |
163 | + &damon_sysfs_intervals_goal_min_sample_us_attr.attr, | 165 | + &damon_sysfs_intervals_goal_min_sample_us_attr.attr, |
164 | + &damon_sysfs_intervals_goal_max_sample_us_attr.attr, | 166 | + &damon_sysfs_intervals_goal_max_sample_us_attr.attr, |
165 | + NULL, | 167 | + NULL, |
166 | +}; | 168 | +}; |
... | ... | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
21 | sys_attrs->nr_regions_range; | 21 | sys_attrs->nr_regions_range; |
22 | struct damon_attrs attrs = { | 22 | struct damon_attrs attrs = { |
23 | .sample_interval = sys_intervals->sample_us, | 23 | .sample_interval = sys_intervals->sample_us, |
24 | .aggr_interval = sys_intervals->aggr_us, | 24 | .aggr_interval = sys_intervals->aggr_us, |
25 | + .intervals_goal = { | 25 | + .intervals_goal = { |
26 | + .access_bp = sys_goal->access_bp, | 26 | + .samples_bp = sys_goal->samples_bp, |
27 | + .aggrs = sys_goal->aggrs, | 27 | + .aggrs = sys_goal->aggrs, |
28 | + .min_sample_us = sys_goal->min_sample_us, | 28 | + .min_sample_us = sys_goal->min_sample_us, |
29 | + .max_sample_us = sys_goal->max_sample_us}, | 29 | + .max_sample_us = sys_goal->max_sample_us}, |
30 | .ops_update_interval = sys_intervals->update_us, | 30 | .ops_update_interval = sys_intervals->update_us, |
31 | .min_nr_regions = sys_nr_regions->min, | 31 | .min_nr_regions = sys_nr_regions->min, |
32 | .max_nr_regions = sys_nr_regions->max, | 32 | .max_nr_regions = sys_nr_regions->max, |
33 | -- | 33 | -- |
34 | 2.39.5 | 34 | 2.39.5 | diff view generated by jsdifflib |
1 | DAMON kernel API callers can show auto-tuned sampling and aggregation | 1 | DAMON kernel API callers can show auto-tuned sampling and aggregation |
---|---|---|---|
2 | intervals from the monmitoring attributes data structure. That can be | 2 | intervals from the monmitoring attributes data structure. That can be |
3 | useful for debugging or tuning of the feature. DAMON user-space ABI | 3 | useful for debugging or tuning of the feature. DAMON user-space ABI |
4 | users has no way to see that, though. Implement a new DAMON sysfs | 4 | users has no way to see that, though. Implement a new DAMON sysfs |
5 | interface command, namely 'update_tuned_intervals', for the purpose. | 5 | interface kdamond state command, namely 'update_tuned_intervals', for |
6 | If the command is written to the kdamond state file, the tuned sampling | 6 | the purpose. Once the command is written to the kdamond state file, the |
7 | and aggregation intervals will be updated to the corresponding sysfs | 7 | tuned sampling and aggregation intervals will be updated to the |
8 | interface files. | 8 | corresponding sysfs interface. |
9 | 9 | ||
10 | Signed-off-by: SeongJae Park <sj@kernel.org> | 10 | Signed-off-by: SeongJae Park <sj@kernel.org> |
11 | --- | 11 | --- |
12 | mm/damon/sysfs.c | 20 ++++++++++++++++++++ | 12 | mm/damon/sysfs.c | 20 ++++++++++++++++++++ |
13 | 1 file changed, 20 insertions(+) | 13 | 1 file changed, 20 insertions(+) |
... | ... | diff view generated by jsdifflib |
1 | Document the design of DAMON sampling and aggregation intervals | 1 | Document DAMON sampling and aggregation intervals auto-tuning design. |
---|---|---|---|
2 | auto-tuning. | ||
3 | 2 | ||
4 | Signed-off-by: SeongJae Park <sj@kernel.org> | 3 | Signed-off-by: SeongJae Park <sj@kernel.org> |
5 | --- | 4 | --- |
6 | Documentation/mm/damon/design.rst | 46 +++++++++++++++++++++++++++++++ | 5 | Documentation/mm/damon/design.rst | 34 +++++++++++++++++++++++++++++++ |
7 | 1 file changed, 46 insertions(+) | 6 | 1 file changed, 34 insertions(+) |
8 | 7 | ||
9 | diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst | 8 | diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst |
10 | index XXXXXXX..XXXXXXX 100644 | 9 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/Documentation/mm/damon/design.rst | 10 | --- a/Documentation/mm/damon/design.rst |
12 | +++ b/Documentation/mm/damon/design.rst | 11 | +++ b/Documentation/mm/damon/design.rst |
... | ... | ||
31 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 30 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
32 | + | 31 | + |
33 | +DAMON provides automatic tuning of the ``sampling interval`` and ``aggregation | 32 | +DAMON provides automatic tuning of the ``sampling interval`` and ``aggregation |
34 | +interval`` based on the :ref:`the tuning guide idea | 33 | +interval`` based on the :ref:`the tuning guide idea |
35 | +<damon_design_monitoring_params_tuning_guide>`. The tuning mechanism allows | 34 | +<damon_design_monitoring_params_tuning_guide>`. The tuning mechanism allows |
36 | +users to set the aimed amount of access events to observe via DAMON within | 35 | +users to set the aimed amount of heats to observe with DAMON within given time |
37 | +given time interval. The target can be specified by the user as a ratio of | 36 | +interval. The target can be specified by the user as a ratio of access check |
38 | +DAMON-observed access events to the theoretical maximum amount of the events | 37 | +samples that gave positive result to the total samples (``samples_bp``) that |
39 | +(``access_bp``) that measured within a given number of aggregations | 38 | +measured within a given number of aggregations (``aggrs``). The mechanism |
40 | +(``aggrs``). | 39 | +calculates the ratio of access check samples for ``aggrs`` aggregations, and |
41 | + | 40 | +increases or decrease the ``sampleing interval`` and ``aggregation interval`` |
42 | +The DAMON-observed access events are calculated in byte granularity based on | 41 | +in same ratio, if the samples ratio is lower or higher than the target, |
43 | +DAMON :ref:`region assumption <damon_design_region_based_sample>`. For | 42 | +respectively. The ratio of the intervals change is decided in proportion to |
44 | +example, if a region of size ``X`` bytes of ``Y`` ``nr_accesses`` is found, it | 43 | +the distance between current samples ratio and the target ratio. |
45 | +means ``X * Y`` access events are observed by DAMON. Theoretical maximum | ||
46 | +access events for the region is calculated in same way, but replacing ``Y`` | ||
47 | +with theoretical maximum ``nr_accesses``, which can be calculated as | ||
48 | +``aggregation interval / sampling interval``. | ||
49 | + | ||
50 | +The mechanism calculates the ratio of access events for ``aggrs`` aggregations, | ||
51 | +and increases or decrease the ``sampleing interval`` and ``aggregation | ||
52 | +interval`` in same ratio, if the observed access ratio is lower or higher than | ||
53 | +the target, respectively. The ratio of the intervals change is decided in | ||
54 | +proportion to the distance between current samples ratio and the target ratio. | ||
55 | + | 44 | + |
56 | +The user can further set the minimum and maximum ``sampling interval`` that can | 45 | +The user can further set the minimum and maximum ``sampling interval`` that can |
57 | +be set by the tuning mechanism using two parameters (``min_sample_us`` and | 46 | +be set by the tuning mechanism using two parameters (``min_sample_us`` and |
58 | +``max_sample_us``). Because the tuning mechanism changes ``sampling interval`` | 47 | +``max_sample_us``). Because the tuning mechanism changes ``sampling interval`` |
59 | +and ``aggregation interval`` in same ratio always, the minimum and maximum | 48 | +and ``aggregation interval`` in same ratio always, the minimum and maximum |
60 | +``aggregation interval`` after each of the tuning changes can automatically set | 49 | +``aggregation interval`` after each of the tuning changes can automatically set |
61 | +together. | 50 | +together. |
62 | + | 51 | + |
63 | +The tuning is turned off by default, and need to be set explicitly by the user. | 52 | +The tuning is turned off by default, and need to be set explicitly by the user. |
64 | +As a rule of thumbs and the Parreto principle, 4% access samples ratio target | 53 | +As a rule of thumbs and the Parreto principle, 20% access samples ratio target |
65 | +is recommended. Note that Parreto principle (80/20 rule) has applied twice. | 54 | +is recommended. |
66 | +That is, assumes 4% (20% of 20%) DAMON-observed access events ratio (source) | ||
67 | +to capture 64% (80% multipled by 80%) real access events (outcomes). | ||
68 | + | 55 | + |
69 | + | 56 | + |
70 | .. _damon_design_damos: | 57 | .. _damon_design_damos: |
71 | 58 | ||
72 | Operation Schemes | 59 | Operation Schemes |
73 | -- | 60 | -- |
74 | 2.39.5 | 61 | 2.39.5 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
12 | +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon | 12 | +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon |
13 | @@ -XXX,XX +XXX,XX @@ Description: Writing a value to this file sets the update interval of the | 13 | @@ -XXX,XX +XXX,XX @@ Description: Writing a value to this file sets the update interval of the |
14 | DAMON context in microseconds as the value. Reading this file | 14 | DAMON context in microseconds as the value. Reading this file |
15 | returns the value. | 15 | returns the value. |
16 | 16 | ||
17 | +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/access_bp | 17 | +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/samples_bp |
18 | +Date: Feb 2025 | 18 | +Date: Feb 2025 |
19 | +Contact: SeongJae Park <sj@kernel.org> | 19 | +Contact: SeongJae Park <sj@kernel.org> |
20 | +Description: Writing a value to this file sets the monitoring intervals | 20 | +Description: Writing a value to this file sets the monitoring intervals |
21 | + auto-tuning target DAMON-observed access events ratio within | 21 | + auto-tuning target positive access check samples ratio within |
22 | + the given time interval (aggrs in same directory), in bp | 22 | + the given time interval (aggrs in same directory), in bp |
23 | + (1/10,000). Reading this file returns the value. | 23 | + (1/10,000). Reading this file returns the value. |
24 | + | 24 | + |
25 | +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/aggrs | 25 | +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/aggrs |
26 | +Date: Feb 2025 | 26 | +Date: Feb 2025 |
27 | +Contact: SeongJae Park <sj@kernel.org> | 27 | +Contact: SeongJae Park <sj@kernel.org> |
28 | +Description: Writing a value to this file sets the time interval to achieve | 28 | +Description: Writing a value to this file sets the time interval to achieve |
29 | + the monitoring intervals auto-tuning target DAMON-observed | 29 | + the monitoring intervals auto-tuning target positive access |
30 | + access events ratio (access_bp in same directory) within. | 30 | + check samples ratio (samples_bp in same directory) within. |
31 | + Reading this file returns the value. | 31 | + Reading this file returns the value. |
32 | + | 32 | + |
33 | +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/min_sample_us | 33 | +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/min_sample_us |
34 | +Date: Feb 2025 | 34 | +Date: Feb 2025 |
35 | +Contact: SeongJae Park <sj@kernel.org> | 35 | +Contact: SeongJae Park <sj@kernel.org> |
... | ... | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
13 | +++ b/Documentation/admin-guide/mm/damon/usage.rst | 13 | +++ b/Documentation/admin-guide/mm/damon/usage.rst |
14 | @@ -XXX,XX +XXX,XX @@ comma (","). | 14 | @@ -XXX,XX +XXX,XX @@ comma (","). |
15 | │ │ │ │ :ref:`0 <sysfs_context>`/avail_operations,operations | 15 | │ │ │ │ :ref:`0 <sysfs_context>`/avail_operations,operations |
16 | │ │ │ │ │ :ref:`monitoring_attrs <sysfs_monitoring_attrs>`/ | 16 | │ │ │ │ │ :ref:`monitoring_attrs <sysfs_monitoring_attrs>`/ |
17 | │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us | 17 | │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us |
18 | + │ │ │ │ │ │ │ intervals_goal/access_bp,aggrs,min_sample_us,max_sample_us | 18 | + │ │ │ │ │ │ │ intervals_goal/samples_bp,aggrs,min_sample_us,max_sample_us |
19 | │ │ │ │ │ │ nr_regions/min,max | 19 | │ │ │ │ │ │ nr_regions/min,max |
20 | │ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets | 20 | │ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets |
21 | │ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target | 21 | │ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target |
22 | @@ -XXX,XX +XXX,XX @@ Users can write below commands for the kdamond to the ``state`` file. | 22 | @@ -XXX,XX +XXX,XX @@ Users can write below commands for the kdamond to the ``state`` file. |
23 | - ``off``: Stop running. | 23 | - ``off``: Stop running. |
... | ... | ||
41 | +------------------------------------------------------- | 41 | +------------------------------------------------------- |
42 | + | 42 | + |
43 | +Under the ``intervals`` directory, one directory for automated tuning of | 43 | +Under the ``intervals`` directory, one directory for automated tuning of |
44 | +``sample_us`` and ``aggr_us``, namely ``intervals_goal`` directory also exists. | 44 | +``sample_us`` and ``aggr_us``, namely ``intervals_goal`` directory also exists. |
45 | +Under the directory, four files for the auto-tuning control, namely | 45 | +Under the directory, four files for the auto-tuning control, namely |
46 | +``access_bp``, ``aggrs``, ``min_sample_us`` and ``max_sample_us`` exist. | 46 | +``samples_bp``, ``aggrs``, ``min_sample_us`` and ``max_sample_us`` exist. |
47 | +Please refer to the :ref:`design document of the feature | 47 | +Please refer to the :ref:`design document of the feature |
48 | +<damon_design_monitoring_intervals_autotuning>` for the internal of the tuning | 48 | +<damon_design_monitoring_intervals_autotuning>` for the internal of the tuning |
49 | +mechanism. Reading and writing the four files under ``intervals_goal`` | 49 | +mechanism. Reading and writing the four files under ``intervals_goal`` |
50 | +directory shows and updates the tuning parameters that described in the | 50 | +directory shows and updates the tuning parameters that described in the |
51 | +:ref:design doc <damon_design_monitoring_intervals_autotuning>` with the same | 51 | +:ref:design doc <damon_design_monitoring_intervals_autotuning>` with the same |
... | ... | ||
59 | contexts/<N>/targets/ | 59 | contexts/<N>/targets/ |
60 | diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst | 60 | diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst |
61 | index XXXXXXX..XXXXXXX 100644 | 61 | index XXXXXXX..XXXXXXX 100644 |
62 | --- a/Documentation/mm/damon/design.rst | 62 | --- a/Documentation/mm/damon/design.rst |
63 | +++ b/Documentation/mm/damon/design.rst | 63 | +++ b/Documentation/mm/damon/design.rst |
64 | @@ -XXX,XX +XXX,XX @@ is recommended. Note that Parreto principle (80/20 rule) has applied twice. | 64 | @@ -XXX,XX +XXX,XX @@ The tuning is turned off by default, and need to be set explicitly by the user. |
65 | That is, assumes 4% (20% of 20%) DAMON-observed access events ratio (source) | 65 | As a rule of thumbs and the Parreto principle, 20% access samples ratio target |
66 | to capture 64% (80% multipled by 80%) real access events (outcomes). | 66 | is recommended. |
67 | 67 | ||
68 | +To know how user-space can use this feature via :ref:`DAMON sysfs interface | 68 | +To know how user-space can use this feature via :ref:`DAMON sysfs interface |
69 | +<sysfs_interface>`, refer to :ref:`intervals_goal <sysfs_scheme>` part of | 69 | +<sysfs_interface>`, refer to :ref:`intervals_goal <sysfs_scheme>` part of |
70 | +the documentation. | 70 | +the documentation. |
71 | + | 71 | + |
72 | 72 | ||
73 | .. _damon_design_damos: | 73 | .. _damon_design_damos: |
74 | 74 | ||
75 | -- | 75 | -- |
76 | 2.39.5 | 76 | 2.39.5 | diff view generated by jsdifflib |