linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Ravi Jonnalagadda <ravis.opensrc@gmail.com>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	akpm@linux-foundation.org, corbet@lwn.net, bijan311@gmail.com,
	ajayjoshi@micron.com, honggyu.kim@sk.com, yunjeong.mun@sk.com
Subject: Re: [RFC PATCH v3 2/4] mm/damon: fix esz=0 quota bypass allowing unlimited migration
Date: Mon, 23 Feb 2026 17:54:52 -0800	[thread overview]
Message-ID: <20260224015453.56879-1-sj@kernel.org> (raw)
In-Reply-To: <20260223123232.12851-3-ravis.opensrc@gmail.com>

On Mon, 23 Feb 2026 12:32:30 +0000 Ravi Jonnalagadda <ravis.opensrc@gmail.com> wrote:

> When the TEMPORAL goal tuner sets esz_bp=0 to signal that a goal has
> been achieved, the quota check was not actually stopping migration.
> 
> The condition:
>     if (quota->esz && quota->charged_sz >= quota->esz)
> 
> When esz=0, this evaluates to (false && ...) = false, so the continue
> is never executed and migration proceeds without limit.

Nice finding, thank you for sharing this!

> 
> Change the logic to:
>     if (!quota->esz || quota->charged_sz >= quota->esz)
> 
> Now when esz=0, (!0 = true) causes the continue to execute, properly
> stopping migration when the goal is achieved.

But this code is written in the way because the current code assumes zero 'esz'
means it is not being used and therefore be ignored.  This change should be ok
for your use case, but could introduce an unexpected behavioral change for
other users.

One easy workaround would be setting esz_bp with a value smaller than 40960000
instead of 0.  That is, esz_bp is the bytes in bp, so setting it smaller than
40960000 will result in making it effectively zero, e.g., like below.

'''
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2623,7 +2623,7 @@ 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;
+               quota->esz_bp = 10000;
        else if (quota->sz)
                quota->esz_bp = quota->sz * 10000;
        else
'''

But maybe there is a better way to cleanly fix this.  Let me take a time to
think more...


Thanks,
SJ

[...]


  reply	other threads:[~2026-02-24  1:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 12:32 [RFC PATCH v3 0/4] mm/damon: Introduce node_eligible_mem_bp and node_ineligible_mem_bp Quota Goal Metrics Ravi Jonnalagadda
2026-02-23 12:32 ` [RFC PATCH v3 1/4] mm/damon/sysfs: set goal_tuner after scheme creation Ravi Jonnalagadda
2026-02-24  1:40   ` SeongJae Park
2026-02-23 12:32 ` [RFC PATCH v3 2/4] mm/damon: fix esz=0 quota bypass allowing unlimited migration Ravi Jonnalagadda
2026-02-24  1:54   ` SeongJae Park [this message]
2026-02-23 12:32 ` [RFC PATCH v3 3/4] mm/damon: add node_eligible_mem_bp and node_ineligible_mem_bp goal metrics Ravi Jonnalagadda
2026-02-24  4:27   ` SeongJae Park
2026-02-23 12:32 ` [RFC PATCH v4 4/4] mm/damon: add PA-mode cache for eligible memory detection lag Ravi Jonnalagadda

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=20260224015453.56879-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=ajayjoshi@micron.com \
    --cc=akpm@linux-foundation.org \
    --cc=bijan311@gmail.com \
    --cc=corbet@lwn.net \
    --cc=damon@lists.linux.dev \
    --cc=honggyu.kim@sk.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ravis.opensrc@gmail.com \
    --cc=yunjeong.mun@sk.com \
    /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