mm/damon/core: invoke kdamond_call() after merging is done if possible
authorSeongJae Park <sj@kernel.org>
Thu, 6 Mar 2025 17:58:57 +0000 (09:58 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 18 Mar 2025 05:06:54 +0000 (22:06 -0700)
kdamond_call() callers may iterate the regions, so better to call it when
the number of regions is as small as possible.  It is when
kdamond_merge_regions() is finished.  Invoke it on the point.

This change is also aimed to make future changes for carrying online
parameters commit with damon_call() easier.  The commit operation should
be able to make sequence between other aggregation interval based
operations including regioins merging and aggregation reset.  Placing
damon_call() invocation after the regions merging makes the sequence
handling simpler.

Link: https://lkml.kernel.org/r/20250306175908.66300-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/core.c

index ebbb228404352874220450b1bb09130ab1d60033..b9a9db1a90b43061a0a34a9c1230ae07f71b0696 100644 (file)
@@ -2421,7 +2421,6 @@ static int kdamond_fn(void *data)
                if (ctx->callback.after_sampling &&
                                ctx->callback.after_sampling(ctx))
                        break;
-               kdamond_call(ctx, false);
 
                kdamond_usleep(sample_interval);
                ctx->passed_sample_intervals++;
@@ -2439,9 +2438,10 @@ static int kdamond_fn(void *data)
                }
 
                /*
-                * do kdamond_apply_schemes() after kdamond_merge_regions() if
-                * possible, to reduce overhead
+                * do kdamond_call() and kdamond_apply_schemes() after
+                * kdamond_merge_regions() if possible, to reduce overhead
                 */
+               kdamond_call(ctx, false);
                if (!list_empty(&ctx->schemes))
                        kdamond_apply_schemes(ctx);
                else