aboutsummaryrefslogtreecommitdiffstats
path: root/patches/next/mm-damon-core-a-bit-more-cleanup-and-comments.patch
blob: c3f46b24bb2e6717f5e79ab379048087cd66e117 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From f2367ddce6510d1e60021b7d6104637d78b52410 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Tue, 20 Feb 2024 15:59:05 -0800
Subject: [PATCH] mm/damon/core: a bit more cleanup and comments

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 9b777b35ac6d..e799318559a5 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -813,15 +813,15 @@ static int damon_update_scheme(struct damos *dst, struct damos *src)
 	dst->pattern = src->pattern;
 	dst->action = src->action;
 	dst->apply_interval_us = src->apply_interval_us;
+
+	dst->quota.reset_interval = src->quota.reset_interval;
 	dst->quota.ms = src->quota.ms;
 	dst->quota.sz = src->quota.sz;
-	dst->quota.reset_interval = src->quota.reset_interval;
+	damos_update_quota_goals(&dst->quota, &src->quota);
 	dst->quota.weight_sz = src->quota.weight_sz;
 	dst->quota.weight_nr_accesses = src->quota.weight_nr_accesses;
 	dst->quota.weight_age = src->quota.weight_age;
 
-	damos_update_quota_goals(&dst->quota, &src->quota);
-
 	dst->wmarks = src->wmarks;
 
 	err = damos_update_filters(dst, src);
@@ -933,34 +933,36 @@ static int damon_update_targets(struct damon_ctx *dst, struct damon_ctx *src)
 }
 
 /**
- * damon_update_ctx_prams() - Update input parameters of given DAMON context.
- * @old_ctx:	DAMON context that need to be udpated.
- * @new_ctx:	DAMON context that having new user parameters.
+ * damon_update_ctx() - Update input parameters of given DAMON context.
+ * @dst:	DAMON context that need to be udpated.
+ * @src:	DAMON context that having new user parameters.
  *
  * damon_ctx contains user input parameters for monitoring requests, internal
  * status of the monitoring, and the results of the monitoring.  This function
- * updates only input parameters for monitoring requests of @old_ctx with those
- * of @new_ctx, while keeping the internal status and monitoring results.  This
+ * updates only input parameters for monitoring requests of @dst with those
+ * of @src, while keeping the internal status and monitoring results.  This
  * function is aimed to be used for online tuning-like use case.
  */
-int damon_update_ctx(struct damon_ctx *old_ctx, struct damon_ctx *new_ctx)
+int damon_update_ctx(struct damon_ctx *dst, struct damon_ctx *src)
 {
 	int err;
 
-	err = damon_update_schemes(old_ctx, new_ctx);
-	if (err)
-		return err;
-	err = damon_update_targets(old_ctx, new_ctx);
+	err = damon_update_schemes(dst, src);
 	if (err)
 		return err;
-	err = damon_set_attrs(old_ctx, &new_ctx->attrs);
+	err = damon_update_targets(dst, src);
 	if (err)
 		return err;
 	/*
-	 * ->ops update should be done at least after targets update, for pid
-	 * handling
+	 * schemes and targets should be updated first, since
+	 * 1. damon_set_attrs() updates monitoring results of targets and
+	 * next_apply_sis of schemes, and
+	 * 2. ops update should be done after pid handling is done.
 	 */
-	old_ctx->ops = new_ctx->ops;
+	err = damon_set_attrs(dst, &src->attrs);
+	if (err)
+		return err;
+	dst->ops = src->ops;
 
 	return 0;
 }
-- 
2.39.2