All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH v2] mm/damon/core: reset invalid quota->charge_target_from
Date: Thu, 10 Sep 2026 14:43:34 +0000	[thread overview]
Message-ID: <20260910144335.04D261F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910142846.172957-1-sj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] DAMOS scheme processing permanently stalls if a valid target has zero regions, reproducing the exact lockup the patch intended to fix.
--

commit be23af6d135629bfa902e51163989385be75b34b
Author: SJ Park <sj@kernel.org>
One-line subject: mm/damon/core: reset invalid quota->charge_target_from

This commit fixes an issue where DAMOS can suddenly stop working if a target
process that the quota is fully charged on is terminated. It handles this
corner case by catching the invalid target and resetting the charge target
pointer.

> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 645cb367019ae..06cf2ab7e97d7 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3393,8 +3393,15 @@ static void kdamond_apply_schemes(struct damon_ctx *c)
>  	max_region_sz = damon_region_sz_limit(c);
>  	mutex_lock(&c->walk_control_lock);
>  	damon_for_each_target(t, c) {
> -		if (c->ops.target_valid && c->ops.target_valid(t) == false)
> +		if (c->ops.target_valid && c->ops.target_valid(t) == false) {
> +			damon_for_each_scheme(s, c) {
> +				if (s->quota.charge_target_from != t)
> +					continue;
> +				s->quota.charge_target_from = NULL;
> +				s->quota.charge_addr_from = 0;
> +			}
>  			continue;
> +		}
>  		damos_apply_target(c, t, max_region_sz);

[Severity: High]
This is a pre-existing issue, but does this incomplete fix leave DAMOS
vulnerable to permanently stalling when a valid target has zero regions,
or when using operations where target_valid() is not implemented?

If a DAMOS quota is exhausted while applying actions to a target, saving its
pointer to s->quota.charge_target_from, and before the next apply interval
all regions of that target are dynamically removed but the target itself is
kept valid, kdamond_apply_schemes() will process the target here.

Because the target has zero regions, the loop inside damos_apply_target()
is bypassed:

mm/damon/core.c:damos_apply_target() {
	...
	damon_for_each_region(r, t) {
		...
		damon_do_apply_schemes(c, t, r);
		...
	}
}

Consequently, damos_skip_charged_region() is never executed to clear
charge_target_from.

When evaluating all other targets, damos_skip_charged_region() will check
the stale charge_target_from pointer and unconditionally return true,
skipping all actions and permanently stalling scheme processing.

Could we ensure charge_target_from is cleared even if the target has no
regions, or if the target_valid() operation is missing?

>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910142846.172957-1-sj@kernel.org?part=1

  reply	other threads:[~2026-09-10 14:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 14:28 [PATCH v2] mm/damon/core: reset invalid quota->charge_target_from SJ Park
2026-09-10 14:43 ` sashiko-bot [this message]
2026-09-10 14:50   ` 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=20260910144335.04D261F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.