All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Liew Rui Yan" <aethernet65535@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH v2] mm/damon/core: fix unconditionally skip last region
Date: Sun, 30 Aug 2026 06:47:07 +0000	[thread overview]
Message-ID: <20260830064708.40CA61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830063159.6347-1-aethernet65535@gmail.com>

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

Pre-existing issues:
- [High] A preexisting bug causes DAMOS scheme application to permanently stall for all subsequent targets if `quota->charge_target_from` points to a target that becomes invalid or loses all its regions.
--

commit 630d73d512e66245612cbdfe5c49647aa6ed2874
Author: Liew Rui Yan <aethernet65535@gmail.com>

mm/damon/core: fix unconditionally skip last region

This patch fixes an issue where the last region of a tracked target could
be unconditionally skipped and reset without being processed when a scheme
quota is exhausted. By modifying the reset logic, it ensures the last region
is appropriately handled rather than always skipped.

> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 644daf5a16560..fb76b530bbc68 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -2342,36 +2342,39 @@ static bool damos_skip_charged_region(struct damon_target *t,
>  {
>  	struct damos_quota *quota = &s->quota;
>  	unsigned long sz_to_skip;
> +	bool skip = false;
>  
>  	/* Skip previously charged regions */
>  	if (quota->charge_target_from) {
>  		if (t != quota->charge_target_from)
>  			return true;

[Severity: High]
This isn't a bug introduced by this patch, but does this logic cause all
subsequent targets to permanently stall if the target currently stored in
quota->charge_target_from becomes invalid?

If the monitored process dies before the next window, kdamond_apply_schemes()
appears to bypass it without clearing the saved target:

mm/damon/core.c:kdamond_apply_schemes() {
    ...
		if (c->ops.target_valid && c->ops.target_valid(t) == false)
			continue;
		damos_apply_target(c, t, max_region_sz);
    ...
}

Because the target is skipped entirely, we never call damos_apply_target()
and never reach the clearing mechanism inside damos_skip_charged_region().

When this happens, wouldn't all other valid targets continue to evaluate
(t != quota->charge_target_from) as true here, permanently skipping scheme
applications?

It appears a local user could reliably trigger this by setting a restrictive
quota on a memory-intensive process they own, waiting for the quota to
exhaust, and then terminating the process.

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260830063159.6347-1-aethernet65535@gmail.com?part=1

  reply	other threads:[~2026-08-30  6:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  6:31 [PATCH v2] mm/damon/core: fix unconditionally skip last region Liew Rui Yan
2026-08-30  6:47 ` sashiko-bot [this message]
2026-08-30  8:29   ` Liew Rui Yan
2026-08-30 18:38     ` SJ Park
2026-08-31  0:57       ` Liew Rui Yan
2026-09-01  0:21         ` SJ Park
2026-08-30 18:14 ` SJ Park
2026-08-30 18:19   ` 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=20260830064708.40CA61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aethernet65535@gmail.com \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.