[RFC PATCH v3 10/37] mm/damon/sysfs: connect primitives directory with core

SeongJae Park posted 37 patches 1 week, 4 days ago
[RFC PATCH v3 10/37] mm/damon/sysfs: connect primitives directory with core
Posted by SeongJae Park 1 week, 4 days ago
The monitoring_attrs/sample/primitives/ directory is not connected with
the core layer.  Make the connection.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 14478fd79953..16d58cde03e8 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1640,6 +1640,17 @@ static inline bool damon_sysfs_kdamond_running(
 		damon_is_running(kdamond->damon_ctx);
 }
 
+static int damon_sysfs_set_sample_control(
+		struct damon_sample_control *control,
+		struct damon_sysfs_sample *sysfs_sample)
+{
+	control->primitives_enabled.page_table =
+		sysfs_sample->primitives->page_table;
+	control->primitives_enabled.page_fault =
+		sysfs_sample->primitives->page_fault;
+	return 0;
+}
+
 static int damon_sysfs_apply_inputs(struct damon_ctx *ctx,
 		struct damon_sysfs_context *sys_ctx)
 {
@@ -1654,6 +1665,10 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx,
 		ctx->min_sz_region = max(
 				DAMON_MIN_REGION / sys_ctx->addr_unit, 1);
 	err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs);
+	if (err)
+		return err;
+	err = damon_sysfs_set_sample_control(&ctx->sample_control,
+			sys_ctx->attrs->sample);
 	if (err)
 		return err;
 	err = damon_sysfs_add_targets(ctx, sys_ctx->targets);
-- 
2.47.3