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: [RFC PATCH] mm/damon/core: reset invalid quota->charge_target_from
Date: Sun, 06 Sep 2026 18:58:30 +0000	[thread overview]
Message-ID: <20260906185831.535EB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260906183654.95634-1-sj@kernel.org>

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

Pre-existing issues:
- [High] The new `damos_reset_invalid_charge_target_from()` function fails to reset dangling `charge_target_from` pointers for PADDR operations, permanently breaking `damon_reclaim` functionality across restarts.
--

commit 6f10f4f2fc1ae76229671b5157f9aa34aed9227b
Author: SJ Park <sj@kernel.org>

    mm/damon/core: reset invalid quota->charge_target_from

This commit fixes an issue where DAMOS suddenly stops working if a target
process that a quota just fully charged in is terminated. It catches this
corner case and resets the invalid quota->charge_target_from pointer.

Link: https://lore.kernel.org/20260830064708.40CA61F000E9@smtp.kernel.org

> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index ce8c6f99106ed..2c58be9edbde4 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3283,6 +3283,22 @@ static void damos_trace_esz(struct damon_ctx *c, struct damos *s,
>  	trace_damos_esz(cidx, sidx, quota->esz);
>  }
>  
> +static void damos_reset_invalid_charge_target_from(struct damos_quota *quota,
> +		struct damon_ctx *c)
> +{
> +	struct damon_target *t;
> +
> +	t = quota->charge_target_from;
> +	if (!t)
> +		return;
> +	if (!c->ops.target_valid)
> +		return;

[Severity: High]
This is a pre-existing issue, but by returning early here, does this new
function fail to clear dangling charge_target_from pointers for PADDR
operations (like damon_reclaim)?

If damon_reclaim is enabled with quotas and hits quota exhaustion,
quota->charge_target_from is set. If damon_reclaim is then disabled,
damon_stop() destroys the targets, leaving charge_target_from as a dangling
pointer.

When damon_reclaim is re-enabled, a new target is created. Because
target_valid is NULL for PADDR operations, this new function returns early.

Could this lead to damos_skip_charged_region() comparing the new target
against the dangling pointer, evaluating to true, and permanently skipping
all memory reclaim actions?

> +	if (c->ops.target_valid(t))
> +		return;
> +	quota->charge_target_from = NULL;
> +	quota->charge_addr_from = 0;
> +}
>
>  static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)

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

  reply	other threads:[~2026-09-06 18:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 18:36 [RFC PATCH] mm/damon/core: reset invalid quota->charge_target_from SJ Park
2026-09-06 18:58 ` sashiko-bot [this message]
2026-09-06 19:11   ` 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=20260906185831.535EB1F00A3A@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.