Skip to content

Commit 65cc56d

Browse files
sjp38akpm00
authored andcommitted
samples/damon/wsse: implement working set size estimation and logging
Implement the DAMON-based working set size estimation logic. The logic iterates memory regions in DAMON-generated access pattern snapshot for every aggregation interval and get the total sum of the size of any region having one or higher 'nr_accesses' count. That is, it assumes any region having one or higher 'nr_accesses' to be a part of the working set. The estimated value is reported to the user by printing it to the kernel log. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b757c6c commit 65cc56d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

samples/damon/wsse.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ MODULE_PARM_DESC(enable, "Enable or disable DAMON_SAMPLE_WSSE");
3030
static struct damon_ctx *ctx;
3131
static struct pid *target_pidp;
3232

33+
static int damon_sample_wsse_after_aggregate(struct damon_ctx *c)
34+
{
35+
struct damon_target *t;
36+
37+
damon_for_each_target(t, c) {
38+
struct damon_region *r;
39+
unsigned long wss = 0;
40+
41+
damon_for_each_region(r, t) {
42+
if (r->nr_accesses > 0)
43+
wss += r->ar.end - r->ar.start;
44+
}
45+
pr_info("wss: %lu\n", wss);
46+
}
47+
return 0;
48+
}
49+
3350
static int damon_sample_wsse_start(void)
3451
{
3552
struct damon_target *target;
@@ -57,6 +74,7 @@ static int damon_sample_wsse_start(void)
5774
}
5875
target->pid = target_pidp;
5976

77+
ctx->callback.after_aggregation = damon_sample_wsse_after_aggregate;
6078
return damon_start(&ctx, 1, true);
6179
}
6280

0 commit comments

Comments
 (0)