From: Gutierrez Asier <gutierrez.asier@huawei-partners.com>
To: SJ Park <sj@kernel.org>, Andrew Morton <akpm@linux-foundation.org>
Cc: <damon@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>
Subject: Re: [PATCH 1/8] mm/damon/core: introduce damos_quota_goal->complement
Date: Tue, 29 Sep 2026 13:24:20 +0300 [thread overview]
Message-ID: <9e07dbdd-3b02-4175-b343-c8cb6f9885e0@huawei-partners.com> (raw)
In-Reply-To: <20260929080113.41708-2-sj@kernel.org>
Hi SJ,
On 9/29/2026 11:01 AM, SJ Park wrote:
> Introduce damos_quota_goal->complement for specifying whether to use a
> complemented value of the given goal target metric. Add the field to
> the data structure and implement essential core support. Handle the
> flag in the quota goal commit and current quota goal metric value
> retrieval.
>
> Signed-off-by: SJ Park <sj@kernel.org>
> ---
> include/linux/damon.h | 2 ++
> mm/damon/core.c | 26 +++++++++++++++++++++++++-
> 2 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index 6a29dc2ac8db..42234839ce29 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -169,6 +169,7 @@ enum damos_quota_goal_metric {
> /**
> * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal.
> * @metric: Metric to be used for representing the goal.
> + * @complement: Use the complement of the metric.
> * @target_value: Target value of @metric to achieve with the tuning.
> * @current_value: Current value of @metric.
> * @nid: Node id.
> @@ -191,6 +192,7 @@ enum damos_quota_goal_metric {
> */
> struct damos_quota_goal {
> enum damos_quota_goal_metric metric;
> + bool complement;
> unsigned long target_value;
> unsigned long current_value;
> /* metric-dependent fields */
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 5ecbea5d71e1..1ab5154511e6 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -1224,6 +1224,7 @@ static int damos_commit_quota_goal(
> if (!src->target_value)
> return -EINVAL;
> dst->metric = src->metric;
> + dst->complement = src->complement;
> dst->target_value = src->target_value;
> if (dst->metric == DAMOS_QUOTA_USER_INPUT)
> dst->current_value = src->current_value;
> @@ -2960,10 +2961,18 @@ static void damos_set_psi_current_val(u64 now_psi_total,
> struct damos_quota_goal *goal, struct damos *s)
> {
> u64 last_psi_total = goal->last_psi_total;
> + unsigned long val;
>
> goal->last_psi_total = now_psi_total;
> if (last_psi_total != U64_MAX) {
> - goal->current_value = now_psi_total - last_psi_total;
> + val = now_psi_total - last_psi_total;
> + if (goal->complement) {
> + if (val < s->quota.reset_interval * 1000)
> + val = s->quota.reset_interval * 1000 - val;
> + else
> + val = 0;
> + }
> + goal->current_value = val;
> return;
> }
> /* uninitialized last_psi_total; make no effect this round */
> @@ -3255,6 +3264,21 @@ static void damos_set_quota_goal_current_value(struct damon_ctx *c,
> default:
> break;
> }
> + if (!goal->complement)
> + return;
> +
> + /* updte current_value to complemented value */
There is a typo there. It should be "update". Also, what is the
purpose of this comment? It doesn't explain anything, which may
not be obvious.> +
> + /* for user_input, users set complemented value on their own */
> + if (goal->metric == DAMOS_QUOTA_USER_INPUT)
> + return;
> + /* damos_set_psi_current_val() handles complement flag itself */
> + if (goal->metric == DAMOS_QUOTA_SOME_MEM_PSI_US)
> + return;
> + if (goal->current_value < 10000)
> + goal->current_value = 10000 - goal->current_value;
> + else
> + goal->current_value = 0;
> }
>
> /* Return the highest score since it makes schemes least aggressive */
--
Asier Gutierrez
Huawei
next prev parent reply other threads:[~2026-09-29 10:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 8:01 [PATCH 0/8] mm/damon: introduce damos quota goal target metric complement flag SJ Park
2026-09-29 8:01 ` [PATCH 1/8] mm/damon/core: introduce damos_quota_goal->complement SJ Park
2026-09-29 10:24 ` Gutierrez Asier [this message]
2026-09-29 10:34 ` SJ Park
2026-09-29 8:01 ` [PATCH 2/8] mm/damon/core: add complement argument to damos_new_quota_goal() SJ Park
2026-09-29 10:25 ` Gutierrez Asier
2026-09-29 8:01 ` [PATCH 3/8] mm/damon/sysfs-schemes: support quota goal complement flag SJ Park
2026-09-29 8:01 ` [PATCH 4/8] mm/damon/tests/core-kunit: test quota_goal->complement commit SJ Park
2026-09-29 8:01 ` [PATCH 5/8] selftests/damon/sysfs.sh: test quota goal complement flag file SJ Park
2026-09-29 8:01 ` [PATCH 6/8] Docs/mm/damon/design: document damos quota goal complement flag SJ Park
2026-09-29 8:01 ` [PATCH 7/8] Docs/admin-guide/mm/damon/usage: update for quota goal complement file SJ Park
2026-09-29 8:01 ` [PATCH 8/8] Docs/ABI/damon: update for quota goal metric complement sysfs file SJ Park
2026-09-29 8:17 ` [PATCH 0/8] mm/damon: introduce damos quota goal target metric complement flag SJ Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9e07dbdd-3b02-4175-b343-c8cb6f9885e0@huawei-partners.com \
--to=gutierrez.asier@huawei-partners.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®