diff mbox series

[v6,05/14] mm/damon: Implement callbacks

Message ID 20200224123047.32506-6-sjpark@amazon.com (mailing list archive)
State New, archived
Headers show
Series Introduce Data Access MONitor (DAMON) | expand

Commit Message

SeongJae Park Feb. 24, 2020, 12:30 p.m. UTC
From: SeongJae Park <sjpark@amazon.de>

This commit implements callbacks for DAMON.  Using this, DAMON users can
install their callbacks for each step of the access monitoring so that
they can do something interesting with the monitored access pattrns
online.  For example, callbacks can report the monitored patterns to
users or do some access pattern based memory management such as
proactive reclamations or access pattern based THP promotions/demotions
decision makings.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
---
 mm/damon.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jonathan Cameron March 10, 2020, 9:01 a.m. UTC | #1
On Mon, 24 Feb 2020 13:30:38 +0100
SeongJae Park <sjpark@amazon.com> wrote:

> From: SeongJae Park <sjpark@amazon.de>
> 
> This commit implements callbacks for DAMON.  Using this, DAMON users can
> install their callbacks for each step of the access monitoring so that
> they can do something interesting with the monitored access pattrns

patterns

> online.  For example, callbacks can report the monitored patterns to
> users or do some access pattern based memory management such as
> proactive reclamations or access pattern based THP promotions/demotions
> decision makings.
> 
> Signed-off-by: SeongJae Park <sjpark@amazon.de>
> ---
>  mm/damon.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/mm/damon.c b/mm/damon.c
> index 6a17408e83c2..554720778e8a 100644
> --- a/mm/damon.c
> +++ b/mm/damon.c
> @@ -83,6 +83,10 @@ struct damon_ctx {
>  	struct rnd_state rndseed;
>  
>  	struct list_head tasks_list;	/* 'damon_task' objects */
> +
> +	/* callbacks */
> +	void (*sample_cb)(struct damon_ctx *context);
> +	void (*aggregate_cb)(struct damon_ctx *context);
>  };
>  
>  /* Get a random number in [l, r) */
> @@ -814,9 +818,13 @@ static int kdamond_fn(void *data)
>  			}
>  			mmput(mm);
>  		}
> +		if (ctx->sample_cb)
> +			ctx->sample_cb(ctx);
>  
>  		if (kdamond_aggregate_interval_passed(ctx)) {
>  			kdamond_merge_regions(ctx, max_nr_accesses / 10);
> +			if (ctx->aggregate_cb)
> +				ctx->aggregate_cb(ctx);
>  			kdamond_flush_aggregated(ctx);
>  			kdamond_split_regions(ctx);
>  		}
diff mbox series

Patch

diff --git a/mm/damon.c b/mm/damon.c
index 6a17408e83c2..554720778e8a 100644
--- a/mm/damon.c
+++ b/mm/damon.c
@@ -83,6 +83,10 @@  struct damon_ctx {
 	struct rnd_state rndseed;
 
 	struct list_head tasks_list;	/* 'damon_task' objects */
+
+	/* callbacks */
+	void (*sample_cb)(struct damon_ctx *context);
+	void (*aggregate_cb)(struct damon_ctx *context);
 };
 
 /* Get a random number in [l, r) */
@@ -814,9 +818,13 @@  static int kdamond_fn(void *data)
 			}
 			mmput(mm);
 		}
+		if (ctx->sample_cb)
+			ctx->sample_cb(ctx);
 
 		if (kdamond_aggregate_interval_passed(ctx)) {
 			kdamond_merge_regions(ctx, max_nr_accesses / 10);
+			if (ctx->aggregate_cb)
+				ctx->aggregate_cb(ctx);
 			kdamond_flush_aggregated(ctx);
 			kdamond_split_regions(ctx);
 		}