DAMON development mailing list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "SeongJae Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 6.12.y 2/2] mm/damon/lru_sort: detect and use fresh enabled and kdamond_pid values
Date: Thu, 14 May 2026 01:49:45 +0000	[thread overview]
Message-ID: <20260514014945.766F4C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260513040734.144259-2-sj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit fixes a state synchronization bug in `mm/damon/lru_sort.c` but misses the identical bug in `mm/damon/reclaim.c`.
--

commit 1cc3b4aed4385359f20cea12e2233bf01f20b6b6
Author: SeongJae Park <sj@kernel.org>

mm/damon/lru_sort: detect and use fresh enabled and kdamond_pid values

This commit updates DAMON_LRU_SORT to dynamically check the 'enabled' and
'kdamond_pid' statuses instead of relying on cached values. This prevents
a state synchronization bug where stale parameters could prevent restarting
DAMON after an unintentional stop.

Link: https://lore.kernel.org/20260419161003.79176-3-sj@kernel.org

> diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
> index 5654e31a198a4..4fdc5c76ff109 100644
> --- a/mm/damon/lru_sort.c
> +++ b/mm/damon/lru_sort.c
[ ... ]
> @@ -239,60 +230,93 @@ static int damon_lru_sort_turn(bool on)
[ ... ]
>  static int damon_lru_sort_enabled_store(const char *val,
>  		const struct kernel_param *kp)
>  {
> -	bool is_enabled = enabled;
> -	bool enable;
>  	int err;
>  
> -	err = kstrtobool(val, &enable);
> +	err = kstrtobool(val, &enabled);
>  	if (err)
>  		return err;
>  
> -	if (is_enabled == enable)
> +	if (damon_lru_sort_enabled() == enabled)
>  		return 0;

Should this same fix be applied to mm/damon/reclaim.c?

It appears DAMON LRU Sort and DAMON Reclaim share identical module parameter
logic. In mm/damon/reclaim.c, damon_reclaim_enabled_store() still uses the
cached enabled variable:

static int damon_reclaim_enabled_store(const char *val,
		const struct kernel_param *kp)
{
	bool is_enabled = enabled;
	bool enable;
	int err;

	err = kstrtobool(val, &enable);
	if (err)
		return err;

	if (is_enabled == enable)
		return 0;

If the kdamond thread stops automatically there, would leaving this identical
logic cause an issue where the stale enabled and kdamond_pid values prevent
the user from restarting it without a reboot?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/2026051241-thievish-uncurious-73fe@gregkh?part=2

  reply	other threads:[~2026-05-14  1:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2026051241-thievish-uncurious-73fe@gregkh>
2026-05-13  4:07 ` [PATCH 6.12.y 1/2] mm/damon/core: implement damon_kdamond_pid() SeongJae Park
2026-05-13  4:07 ` [PATCH 6.12.y 2/2] mm/damon/lru_sort: detect and use fresh enabled and kdamond_pid values SeongJae Park
2026-05-14  1:49   ` sashiko-bot [this message]
2026-05-14  4:47     ` SeongJae 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=20260514014945.766F4C19425@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox