12
12
#include <linux/time64.h>
13
13
#include <linux/types.h>
14
14
15
+ /* Minimal region size. Every damon_region is aligned by this. */
16
+ #define DAMON_MIN_REGION PAGE_SIZE
17
+
15
18
/**
16
19
* struct damon_addr_range - Represents an address region of [@start, @end).
17
20
* @start: Start address of the region (inclusive).
@@ -39,6 +42,7 @@ struct damon_region {
39
42
/**
40
43
* struct damon_target - Represents a monitoring target.
41
44
* @id: Unique identifier for this target.
45
+ * @nr_regions: Number of monitoring target regions of this target.
42
46
* @regions_list: Head of the monitoring target regions of this target.
43
47
* @list: List head for siblings.
44
48
*
@@ -50,6 +54,7 @@ struct damon_region {
50
54
*/
51
55
struct damon_target {
52
56
unsigned long id ;
57
+ unsigned int nr_regions ;
53
58
struct list_head regions_list ;
54
59
struct list_head list ;
55
60
};
@@ -85,6 +90,8 @@ struct damon_ctx;
85
90
* prepared for the next access check.
86
91
* @check_accesses should check the accesses to each region that made after the
87
92
* last preparation and update the number of observed accesses of each region.
93
+ * It should also return max number of observed accesses that made as a result
94
+ * of its update. The value will be used for regions adjustment threshold.
88
95
* @reset_aggregated should reset the access monitoring results that aggregated
89
96
* by @check_accesses.
90
97
* @target_valid should check whether the target is still valid for the
@@ -95,7 +102,7 @@ struct damon_primitive {
95
102
void (* init )(struct damon_ctx * context );
96
103
void (* update )(struct damon_ctx * context );
97
104
void (* prepare_access_checks )(struct damon_ctx * context );
98
- void (* check_accesses )(struct damon_ctx * context );
105
+ unsigned int (* check_accesses )(struct damon_ctx * context );
99
106
void (* reset_aggregated )(struct damon_ctx * context );
100
107
bool (* target_valid )(void * target );
101
108
void (* cleanup )(struct damon_ctx * context );
@@ -172,7 +179,9 @@ struct damon_callback {
172
179
* @primitive: Set of monitoring primitives for given use cases.
173
180
* @callback: Set of callbacks for monitoring events notifications.
174
181
*
175
- * @region_targets: Head of monitoring targets (&damon_target) list.
182
+ * @min_nr_regions: The minimum number of adaptive monitoring regions.
183
+ * @max_nr_regions: The maximum number of adaptive monitoring regions.
184
+ * @adaptive_targets: Head of monitoring targets (&damon_target) list.
176
185
*/
177
186
struct damon_ctx {
178
187
unsigned long sample_interval ;
@@ -191,7 +200,9 @@ struct damon_ctx {
191
200
struct damon_primitive primitive ;
192
201
struct damon_callback callback ;
193
202
194
- struct list_head region_targets ;
203
+ unsigned long min_nr_regions ;
204
+ unsigned long max_nr_regions ;
205
+ struct list_head adaptive_targets ;
195
206
};
196
207
197
208
#define damon_next_region (r ) \
@@ -207,28 +218,31 @@ struct damon_ctx {
207
218
list_for_each_entry_safe(r, next, &t->regions_list, list)
208
219
209
220
#define damon_for_each_target (t , ctx ) \
210
- list_for_each_entry(t, &(ctx)->region_targets , list)
221
+ list_for_each_entry(t, &(ctx)->adaptive_targets , list)
211
222
212
223
#define damon_for_each_target_safe (t , next , ctx ) \
213
- list_for_each_entry_safe(t, next, &(ctx)->region_targets , list)
224
+ list_for_each_entry_safe(t, next, &(ctx)->adaptive_targets , list)
214
225
215
226
#ifdef CONFIG_DAMON
216
227
217
228
struct damon_region * damon_new_region (unsigned long start , unsigned long end );
218
229
inline void damon_insert_region (struct damon_region * r ,
219
- struct damon_region * prev , struct damon_region * next );
230
+ struct damon_region * prev , struct damon_region * next ,
231
+ struct damon_target * t );
220
232
void damon_add_region (struct damon_region * r , struct damon_target * t );
221
- void damon_destroy_region (struct damon_region * r );
233
+ void damon_destroy_region (struct damon_region * r , struct damon_target * t );
222
234
223
235
struct damon_target * damon_new_target (unsigned long id );
224
236
void damon_add_target (struct damon_ctx * ctx , struct damon_target * t );
225
237
void damon_free_target (struct damon_target * t );
226
238
void damon_destroy_target (struct damon_target * t );
239
+ unsigned int damon_nr_regions (struct damon_target * t );
227
240
228
241
struct damon_ctx * damon_new_ctx (void );
229
242
void damon_destroy_ctx (struct damon_ctx * ctx );
230
243
int damon_set_attrs (struct damon_ctx * ctx , unsigned long sample_int ,
231
- unsigned long aggr_int , unsigned long primitive_upd_int );
244
+ unsigned long aggr_int , unsigned long primitive_upd_int ,
245
+ unsigned long min_nr_reg , unsigned long max_nr_reg );
232
246
233
247
int damon_start (struct damon_ctx * * ctxs , int nr_ctxs );
234
248
int damon_stop (struct damon_ctx * * ctxs , int nr_ctxs );
0 commit comments