mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 2/8] mm/damon/core: add complement argument to damos_new_quota_goal()
Date: Tue, 29 Sep 2026 13:25:57 +0300	[thread overview]
Message-ID: <c19759f2-c28c-4b7e-a587-0a4087e85997@huawei-partners.com> (raw)
In-Reply-To: <20260929080113.41708-3-sj@kernel.org>



On 9/29/2026 11:01 AM, SJ Park wrote:
> damos_quota_goal->complement needs to be manually set by each API
> callers.  It is easy to make mistakes.  Extend the quota goal
> constructor, damos_new_quota_goal() to receive and set the complement
> flag value. Also update all callers to use the new signature.
> 
> Signed-off-by: SJ Park <sj@kernel.org>
> ---
>  include/linux/damon.h       | 2 +-
>  mm/damon/core.c             | 7 ++++---
>  mm/damon/lru_sort.c         | 5 +++--
>  mm/damon/reclaim.c          | 5 +++--
>  mm/damon/sysfs-schemes.c    | 2 +-
>  mm/damon/tests/core-kunit.h | 3 ++-
>  samples/damon/mtier.c       | 2 +-
>  7 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index 42234839ce29..63050eb2206a 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -1090,7 +1090,7 @@ bool damos_filter_for_ops(enum damos_filter_type type);
>  void damos_destroy_filter(struct damos_filter *f);
>  
>  struct damos_quota_goal *damos_new_quota_goal(
> -		enum damos_quota_goal_metric metric,
> +		enum damos_quota_goal_metric metric, bool complement,
>  		unsigned long target_value);
>  void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g);
>  void damos_destroy_quota_goal(struct damos_quota_goal *goal);
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 1ab5154511e6..86fee9ca03a4 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -691,7 +691,7 @@ void damos_destroy_filter(struct damos_filter *f)
>  }
>  
>  struct damos_quota_goal *damos_new_quota_goal(
> -		enum damos_quota_goal_metric metric,
> +		enum damos_quota_goal_metric metric, bool complement,
>  		unsigned long target_value)
>  {
>  	struct damos_quota_goal *goal;
> @@ -700,6 +700,7 @@ struct damos_quota_goal *damos_new_quota_goal(
>  	if (!goal)
>  		return NULL;
>  	goal->metric = metric;
> +	goal->complement = complement;
>  	goal->target_value = target_value;
>  	if (metric == DAMOS_QUOTA_SOME_MEM_PSI_US)
>  		goal->last_psi_total = U64_MAX;
> @@ -1262,8 +1263,8 @@ int damos_commit_quota_goals(struct damos_quota *dst, struct damos_quota *src)
>  	damos_for_each_quota_goal_safe(src_goal, next, src) {
>  		if (j++ < i)
>  			continue;
> -		new_goal = damos_new_quota_goal(
> -				src_goal->metric, src_goal->target_value);
> +		new_goal = damos_new_quota_goal(src_goal->metric,
> +				src_goal->complement, src_goal->target_value);
>  		if (!new_goal)
>  			return -ENOMEM;
>  		err = damos_commit_quota_goal(new_goal, src_goal);
> diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
> index 273efa3c913e..64e086985eb5 100644
> --- a/mm/damon/lru_sort.c
> +++ b/mm/damon/lru_sort.c
> @@ -233,12 +233,13 @@ static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme,
>  
>  	if (!active_mem_bp)
>  		return 0;
> -	goal = damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, active_mem_bp);
> +	goal = damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, false,
> +			active_mem_bp);
>  	if (!goal)
>  		return -ENOMEM;
>  	damos_add_quota_goal(&hot_scheme->quota, goal);
>  	/* aim 0.2 % goal conflict, to keep little ping pong */
> -	goal = damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP,
> +	goal = damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP, false,
>  			10000 - active_mem_bp + 2);
>  	if (!goal)
>  		return -ENOMEM;
> diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
> index 42a2c9cb1343..014b0779ea6d 100644
> --- a/mm/damon/reclaim.c
> +++ b/mm/damon/reclaim.c
> @@ -233,7 +233,7 @@ static int damon_reclaim_apply_parameters(void)
>  	damon_set_schemes(param_ctx, &scheme, 1);
>  
>  	if (quota_mem_pressure_us) {
> -		goal = damos_new_quota_goal(DAMOS_QUOTA_SOME_MEM_PSI_US,
> +		goal = damos_new_quota_goal(DAMOS_QUOTA_SOME_MEM_PSI_US, false,
>  				quota_mem_pressure_us);
>  		if (!goal)
>  			goto out;
> @@ -241,7 +241,8 @@ static int damon_reclaim_apply_parameters(void)
>  	}
>  
>  	if (quota_autotune_feedback) {
> -		goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000);
> +		goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, false,
> +				10000);
>  		if (!goal)
>  			goto out;
>  		goal->current_value = quota_autotune_feedback;
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index bfb6f0bc3f21..06af417bc9a2 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
> @@ -2869,7 +2869,7 @@ static int damos_sysfs_add_quota_score(
>  		if (!sysfs_goal->target_value)
>  			continue;
>  
> -		goal = damos_new_quota_goal(sysfs_goal->metric,
> +		goal = damos_new_quota_goal(sysfs_goal->metric, false,
>  				sysfs_goal->target_value);
>  		if (!goal)
>  			return -ENOMEM;
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 2111faa58153..5a924edb171f 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -1014,6 +1014,7 @@ static void damos_test_commit_quota_goals_for(struct kunit *test,
>  		 * Make it kfree()-able.
>  		 */
>  		goal = damos_new_quota_goal(dst_goals[i].metric,
> +				dst_goals[i].complement,
>  				dst_goals[i].target_value);
>  		if (!goal)
>  			goto out;
> @@ -2411,7 +2412,7 @@ static void damos_test_esz_goal_temporal(struct kunit *test)
>  	}
>  	damon_add_scheme(ctx, s);
>  
> -	goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000);
> +	goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, false, 10000);
>  	if (!goal) {
>  		damon_destroy_ctx(ctx);
>  		kunit_skip(test, "quota goal alloc fail");
> diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
> index 27dc88bdf7a0..a2e311082cd4 100644
> --- a/samples/damon/mtier.c
> +++ b/samples/damon/mtier.c
> @@ -163,7 +163,7 @@ static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote)
>  	damon_set_schemes(ctx, &scheme, 1);
>  	quota_goal = damos_new_quota_goal(
>  			promote ? DAMOS_QUOTA_NODE_MEM_USED_BP :
> -			DAMOS_QUOTA_NODE_MEM_FREE_BP,
> +			DAMOS_QUOTA_NODE_MEM_FREE_BP, false,
>  			promote ? node0_mem_used_bp : node0_mem_free_bp);
>  	if (!quota_goal)
>  		goto free_out;

LGTM

Reviewed-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>

-- 
Asier Gutierrez
Huawei


  reply	other threads:[~2026-09-29 10:26 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
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 [this message]
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=c19759f2-c28c-4b7e-a587-0a4087e85997@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®