mm/damon/core: introduce DAMOS_QUOTA_GOAL_TUNER_TEMPORAL

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>
This commit is contained in:
SeongJae Park
2026-03-09 18:05:19 -07:00
committed by Andrew Morton
parent 54419bbd0e
commit af738a6a00
2 changed files with 26 additions and 5 deletions

View 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,
};
/**

View 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;
}