Skip to content

Commit 2fcb936

Browse files
sj-awstorvalds
authored andcommitted
mm/damon: add a tracepoint
This commit adds a tracepoint for DAMON. It traces the monitoring results of each region for each aggregation interval. Using this, DAMON can easily integrated with tracepoints supporting tools such as perf. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Reviewed-by: Leonard Foerster <[email protected]> Reviewed-by: Steven Rostedt (VMware) <[email protected]> Reviewed-by: Fernand Sieber <[email protected]> Acked-by: Shakeel Butt <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Amit Shah <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Brendan Higgins <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: David Rientjes <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Fan Du <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Greg Thelen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Joe Perches <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Marco Elver <[email protected]> Cc: Markus Boehme <[email protected]> Cc: Maximilian Heyne <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3f49584 commit 2fcb936

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

include/trace/events/damon.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#undef TRACE_SYSTEM
3+
#define TRACE_SYSTEM damon
4+
5+
#if !defined(_TRACE_DAMON_H) || defined(TRACE_HEADER_MULTI_READ)
6+
#define _TRACE_DAMON_H
7+
8+
#include <linux/damon.h>
9+
#include <linux/types.h>
10+
#include <linux/tracepoint.h>
11+
12+
TRACE_EVENT(damon_aggregated,
13+
14+
TP_PROTO(struct damon_target *t, struct damon_region *r,
15+
unsigned int nr_regions),
16+
17+
TP_ARGS(t, r, nr_regions),
18+
19+
TP_STRUCT__entry(
20+
__field(unsigned long, target_id)
21+
__field(unsigned int, nr_regions)
22+
__field(unsigned long, start)
23+
__field(unsigned long, end)
24+
__field(unsigned int, nr_accesses)
25+
),
26+
27+
TP_fast_assign(
28+
__entry->target_id = t->id;
29+
__entry->nr_regions = nr_regions;
30+
__entry->start = r->ar.start;
31+
__entry->end = r->ar.end;
32+
__entry->nr_accesses = r->nr_accesses;
33+
),
34+
35+
TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u",
36+
__entry->target_id, __entry->nr_regions,
37+
__entry->start, __entry->end, __entry->nr_accesses)
38+
);
39+
40+
#endif /* _TRACE_DAMON_H */
41+
42+
/* This part must be outside protection */
43+
#include <trace/define_trace.h>

mm/damon/core.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <linux/random.h>
1414
#include <linux/slab.h>
1515

16+
#define CREATE_TRACE_POINTS
17+
#include <trace/events/damon.h>
18+
1619
/* Get a random number in [l, r) */
1720
#define damon_rand(l, r) (l + prandom_u32_max(r - l))
1821

@@ -387,8 +390,10 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
387390
damon_for_each_target(t, c) {
388391
struct damon_region *r;
389392

390-
damon_for_each_region(r, t)
393+
damon_for_each_region(r, t) {
394+
trace_damon_aggregated(t, r, damon_nr_regions(t));
391395
r->nr_accesses = 0;
396+
}
392397
}
393398
}
394399

0 commit comments

Comments
 (0)