Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/stat: calculate and expose estimated memory bandwidth

The raw form of DAMON's monitoring results captures many details of the
information. However, not every bit of the information is always required
for understanding practical access patterns. Especially on real world
production systems of high scale time and size, the raw form is difficult
to be aggregated and compared.

Convert the raw monitoring results into a single number metric, namely
estimated memory bandwidth and expose it to users as a read-only
DAMON_STAT parameter. The metric represents access intensiveness
(hotness) of the system. It can easily be aggregated and compared for
high level understanding of the access pattern on large systems.

Link: https://lkml.kernel.org/r/20250604183127.13968-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
fabdd1e9 369c415e

+35
+35
mm/damon/stat.c
··· 29 29 module_param_cb(enabled, &enabled_param_ops, &enabled, 0600); 30 30 MODULE_PARM_DESC(enabled, "Enable of disable DAMON_STAT"); 31 31 32 + static unsigned long estimated_memory_bandwidth __read_mostly; 33 + module_param(estimated_memory_bandwidth, ulong, 0400); 34 + MODULE_PARM_DESC(estimated_memory_bandwidth, 35 + "Estimated memory bandwidth usage in bytes per second"); 36 + 32 37 static struct damon_ctx *damon_stat_context; 38 + 39 + static void damon_stat_set_estimated_memory_bandwidth(struct damon_ctx *c) 40 + { 41 + struct damon_target *t; 42 + struct damon_region *r; 43 + unsigned long access_bytes = 0; 44 + 45 + damon_for_each_target(t, c) { 46 + damon_for_each_region(r, t) 47 + access_bytes += (r->ar.end - r->ar.start) * 48 + r->nr_accesses; 49 + } 50 + estimated_memory_bandwidth = access_bytes * USEC_PER_MSEC * 51 + MSEC_PER_SEC / c->attrs.aggr_interval; 52 + } 53 + 54 + static int damon_stat_after_aggregation(struct damon_ctx *c) 55 + { 56 + static unsigned long last_refresh_jiffies; 57 + 58 + /* avoid unnecessarily frequent stat update */ 59 + if (time_before_eq(jiffies, last_refresh_jiffies + 60 + msecs_to_jiffies(5 * MSEC_PER_SEC))) 61 + return 0; 62 + last_refresh_jiffies = jiffies; 63 + 64 + damon_stat_set_estimated_memory_bandwidth(c); 65 + return 0; 66 + } 33 67 34 68 static struct damon_ctx *damon_stat_build_ctx(void) 35 69 { ··· 110 76 damon_add_target(ctx, target); 111 77 if (damon_set_region_biggest_system_ram_default(target, &start, &end)) 112 78 goto free_out; 79 + ctx->callback.after_aggregation = damon_stat_after_aggregation; 113 80 return ctx; 114 81 free_out: 115 82 damon_destroy_ctx(ctx);