samples/damon/mtier: fix wrong DAMON attrs setting
Subsystems (2)
SeongJae Park
maintainerPATCH 1/1 samples/damon/mtier: fix wrong DAMON attrs setting
When intervals auto-tuning is enabled, DAMON monitoring attributes should be set with damon_set_attrs(). Because damon_set_attrs() is the only place that sets attrs->aggr_samples, not calling damon_set_attrs() can result in divide-by-zero from damon_get_intervals_score().
mtier, which is a DAMON's sample module that merged in mm-unstable as of this writing, is not calling the function while enabling the auto-tuning. Fix the problem by properly calling damon_set_attrs().
Fixes 3a1fff3fe05b ("samples/damon: implement a DAMON module for memory tiering") # mm-unstable
Signed-off-by SeongJae Park <[email protected]>
--- samples/damon/mtier.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
samples/damon/mtier.c +12 -1
@@ -41,6 +41,7 @@ static struct damon_ctx *ctxs[2];static struct damon_ctx *damon_sample_mtier_build_ctx (bool promote) {struct damon_ctx *ctx; +struct damon_attrs attrs;struct damon_target *target;struct damon_region *region;struct damos *scheme;
@@ -50,14 +51,24 @@ static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote) ctx =damon_new_ctx ();if (!ctx)return NULL ; + attrs = (struct damon_attrs ) { + .sample_interval =5 *USEC_PER_MSEC , + .aggr_interval =100 *USEC_PER_MSEC , + .ops_update_interval =60 *USEC_PER_MSEC *MSEC_PER_SEC , + .min_nr_regions =10 , + .max_nr_regions =1000 , + }; +/* * auto-tune sampling and aggregation interval aiming 4% DAMON-observed * accesses ratio, keeping sampling interval in [5ms, 10s] range. */ - ctx->attrs.intervals_goal = (struct damon_intervals_goal ) { + attrs.intervals_goal = (struct damon_intervals_goal ) { .access_bp =400 , .aggrs =3 , .min_sample_us =5000 , .max_sample_us =10000000 , }; +if (damon_set_attrs (ctx, &attrs)) + goto free_out;if (damon_select_ops (ctx,DAMON_OPS_PADDR )) goto free_out;
base-commit: 882bfccd259e3961b81219834715a70a23f9ea71
Signature · 1 line
2.39.5