Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/core: skip needless update of damon_attrs in damon_commit_ctx()

Currently, damon_commit_ctx() always calls damon_set_attrs() even if the
attributes have not been changed. This can be problematic when the DAMON
state is committed relatively frequently because damon_set_attrs() resets
ctx->next_{aggregation,ops_update}_sis, causing aggregation and ops update
operations to be needlessly delayed.

This patch avoids this by only calling damon_set_attrs() in
damon_commit_ctx when the attributes have been changed.

[akpm@linux-foundation.org:
Link: https://lkml.kernel.org/r/20250807001924.76275-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20250806234254.10572-1-bijan311@gmail.com
Signed-off-by: Bijan Tabatabai <bijantabatab@micron.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Bijan Tabatabai <bijan311@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Bijan Tabatabai and committed by
Andrew Morton
dc32c8d4 878d9e8c

+22 -3
+22 -3
mm/damon/core.c
··· 570 570 kfree(ctx); 571 571 } 572 572 573 + static bool damon_attrs_equals(const struct damon_attrs *attrs1, 574 + const struct damon_attrs *attrs2) 575 + { 576 + const struct damon_intervals_goal *ig1 = &attrs1->intervals_goal; 577 + const struct damon_intervals_goal *ig2 = &attrs2->intervals_goal; 578 + 579 + return attrs1->sample_interval == attrs2->sample_interval && 580 + attrs1->aggr_interval == attrs2->aggr_interval && 581 + attrs1->ops_update_interval == attrs2->ops_update_interval && 582 + attrs1->min_nr_regions == attrs2->min_nr_regions && 583 + attrs1->max_nr_regions == attrs2->max_nr_regions && 584 + ig1->access_bp == ig2->access_bp && 585 + ig1->aggrs == ig2->aggrs && 586 + ig1->min_sample_us == ig2->min_sample_us && 587 + ig1->max_sample_us == ig2->max_sample_us; 588 + } 589 + 573 590 static unsigned int damon_age_for_new_attrs(unsigned int age, 574 591 struct damon_attrs *old_attrs, struct damon_attrs *new_attrs) 575 592 { ··· 1239 1222 * 2. ops update should be done after pid handling is done (target 1240 1223 * committing require putting pids). 1241 1224 */ 1242 - err = damon_set_attrs(dst, &src->attrs); 1243 - if (err) 1244 - return err; 1225 + if (!damon_attrs_equals(&dst->attrs, &src->attrs)) { 1226 + err = damon_set_attrs(dst, &src->attrs); 1227 + if (err) 1228 + return err; 1229 + } 1245 1230 dst->ops = src->ops; 1246 1231 1247 1232 return 0;