]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/damon/core: introduce DAMOS_QUOTA_GOAL_TUNER_TEMPORAL
authorSeongJae Park <sj@kernel.org>
Tue, 10 Mar 2026 01:05:19 +0000 (18:05 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:25 +0000 (13:53 -0700)
Introduce a new goal-based DAMOS quota auto-tuning algorithm, namely
DAMOS_QUOTA_GOAL_TUNER_TEMPORAL (temporal in short).  The algorithm aims
to trigger the DAMOS action only for a temporal time, to achieve the goal
as soon as possible.  For the temporal period, it uses as much quota as
allowed.  Once the goal is achieved, it sets the quota zero, so
effectively makes the scheme be deactivated.

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

index 24de35a8395ac8dd286e1e0865f889d97310eafd..e44e2132ccaf63a35160c5a32f3cd960a152f72b 100644 (file)
@@ -218,9 +218,11 @@ struct damos_quota_goal {
 /**
  * enum damos_quota_goal_tuner - Goal-based quota tuning logic.
  * @DAMOS_QUOTA_GOAL_TUNER_CONSIST:    Aim long term consistent quota.
+ * @DAMOS_QUOTA_GOAL_TUNER_TEMPORAL:   Aim zero quota asap.
  */
 enum damos_quota_goal_tuner {
        DAMOS_QUOTA_GOAL_TUNER_CONSIST,
+       DAMOS_QUOTA_GOAL_TUNER_TEMPORAL,
 };
 
 /**
index db3c59b70e493fce9897326f8b0895810626a895..b543d1202c9d2b393e90c06e86d4a7f8cb4cef24 100644 (file)
@@ -2347,6 +2347,26 @@ static unsigned long damos_quota_score(struct damos_quota *quota)
        return highest_score;
 }
 
+static void damos_goal_tune_esz_bp_consist(struct damos_quota *quota)
+{
+       unsigned long score = damos_quota_score(quota);
+
+       quota->esz_bp = damon_feed_loop_next_input(
+                       max(quota->esz_bp, 10000UL), score);
+}
+
+static void damos_goal_tune_esz_bp_temporal(struct damos_quota *quota)
+{
+       unsigned long score = damos_quota_score(quota);
+
+       if (score >= 10000)
+               quota->esz_bp = 0;
+       else if (quota->sz)
+               quota->esz_bp = quota->sz * 10000;
+       else
+               quota->esz_bp = ULONG_MAX;
+}
+
 /*
  * Called only if quota->ms, or quota->sz are set, or quota->goals is not empty
  */
@@ -2361,11 +2381,10 @@ static void damos_set_effective_quota(struct damos_quota *quota)
        }
 
        if (!list_empty(&quota->goals)) {
-               unsigned long score = damos_quota_score(quota);
-
-               quota->esz_bp = damon_feed_loop_next_input(
-                               max(quota->esz_bp, 10000UL),
-                               score);
+               if (quota->goal_tuner == DAMOS_QUOTA_GOAL_TUNER_CONSIST)
+                       damos_goal_tune_esz_bp_consist(quota);
+               else if (quota->goal_tuner == DAMOS_QUOTA_GOAL_TUNER_TEMPORAL)
+                       damos_goal_tune_esz_bp_temporal(quota);
                esz = quota->esz_bp / 10000;
        }