@@ -185,6 +185,36 @@ module_param(monitor_region_end, ulong, 0600);
185
185
static int kdamond_pid __read_mostly = -1 ;
186
186
module_param (kdamond_pid , int , 0400 );
187
187
188
+ /*
189
+ * Number of memory regions that tried to be reclaimed.
190
+ */
191
+ static unsigned long nr_reclaim_tried_regions __read_mostly ;
192
+ module_param (nr_reclaim_tried_regions , ulong , 0400 );
193
+
194
+ /*
195
+ * Total bytes of memory regions that tried to be reclaimed.
196
+ */
197
+ static unsigned long bytes_reclaim_tried_regions __read_mostly ;
198
+ module_param (bytes_reclaim_tried_regions , ulong , 0400 );
199
+
200
+ /*
201
+ * Number of memory regions that successfully be reclaimed.
202
+ */
203
+ static unsigned long nr_reclaimed_regions __read_mostly ;
204
+ module_param (nr_reclaimed_regions , ulong , 0400 );
205
+
206
+ /*
207
+ * Total bytes of memory regions that successfully be reclaimed.
208
+ */
209
+ static unsigned long bytes_reclaimed_regions __read_mostly ;
210
+ module_param (bytes_reclaimed_regions , ulong , 0400 );
211
+
212
+ /*
213
+ * Number of times that the time/space quota limits have exceeded
214
+ */
215
+ static unsigned long nr_quota_exceeds __read_mostly ;
216
+ module_param (nr_quota_exceeds , ulong , 0400 );
217
+
188
218
static struct damon_ctx * ctx ;
189
219
static struct damon_target * target ;
190
220
@@ -333,13 +363,29 @@ static void damon_reclaim_timer_fn(struct work_struct *work)
333
363
}
334
364
static DECLARE_DELAYED_WORK (damon_reclaim_timer , damon_reclaim_timer_fn ) ;
335
365
366
+ static int damon_reclaim_after_aggregation (struct damon_ctx * c )
367
+ {
368
+ struct damos * s ;
369
+
370
+ /* update the stats parameter */
371
+ damon_for_each_scheme (s , c ) {
372
+ nr_reclaim_tried_regions = s -> stat .nr_tried ;
373
+ bytes_reclaim_tried_regions = s -> stat .sz_tried ;
374
+ nr_reclaimed_regions = s -> stat .nr_applied ;
375
+ bytes_reclaimed_regions = s -> stat .sz_applied ;
376
+ nr_quota_exceeds = s -> stat .qt_exceeds ;
377
+ }
378
+ return 0 ;
379
+ }
380
+
336
381
static int __init damon_reclaim_init (void )
337
382
{
338
383
ctx = damon_new_ctx ();
339
384
if (!ctx )
340
385
return - ENOMEM ;
341
386
342
387
damon_pa_set_primitives (ctx );
388
+ ctx -> callback .after_aggregation = damon_reclaim_after_aggregation ;
343
389
344
390
/* 4242 means nothing but fun */
345
391
target = damon_new_target (4242 );
0 commit comments