DAMON development mailing list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maksym Shcherba" <mshcherba2000@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command
Date: Mon, 18 May 2026 19:57:47 +0000	[thread overview]
Message-ID: <20260518195747.8CF14C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260518190932.42270-2-maksym.shcherba@lnu.edu.ua>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Concurrent lockless modification of the sysfs current_value field causes a data race and silently destroys uncommitted user input.
--

commit 82969e621e89de8b04fc04548d5cd270bf1bb3b7
Author: Maksym Shcherba <mshcherba2000@gmail.com>

mm/damon/sysfs: implement update_schemes_quota_goals command

This commit introduces the DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS
command. It adds the logic to copy the current_value from the internal
damos_quota_goal structure to the damos_sysfs_quota_goal sysfs structure
and integrates it with the sysfs interface.

> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index 622c3799db87b..198a510003143 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c

[ ... ]

> +void damos_sysfs_update_quota_goals(
> +		struct damon_sysfs_schemes *sysfs_schemes,
> +		struct damon_ctx *ctx)
> +{

[ ... ]

> +		damos_for_each_quota_goal(goal, &scheme->quota) {
> +			if (goals_idx >= sysfs_goals->nr)
> +				break;
> +
> +			sysfs_goals->goals_arr[goals_idx++]->current_value =
> +				goal->current_value;

Looking at current_value_store() in mm/damon/sysfs-schemes.c, user input is
written directly to the sysfs goal->current_value without holding
damon_sysfs_lock or using atomic operations.

Since the sysfs writer does not hold the lock, will this concurrent
modification create a data race that triggers KCSAN warnings?

> +		}
> +	}
> +}

> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index d5863cc33d230..ecc880b52b329 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c

[ ... ]

> @@ -1656,6 +1672,7 @@ static int damon_sysfs_repeat_call_fn(void *data)
>  	damon_sysfs_upd_tuned_intervals(sysfs_kdamond);
>  	damon_sysfs_upd_schemes_stats(sysfs_kdamond);
>  	damon_sysfs_upd_schemes_effective_quotas(sysfs_kdamond);
> +	damon_sysfs_upd_schemes_quota_goals(sysfs_kdamond);
>  out:
>  	mutex_unlock(&damon_sysfs_lock);
>  	return 0;

Since damos_sysfs_update_quota_goals() is executed periodically here
(when refresh_ms > 0), the DAMON worker thread can overwrite a user's
uncommitted quota update with the old core state.

For goals using DAMOS_QUOTA_USER_INPUT, could this cause user input to be
lost before they have a chance to execute commit_schemes_quota_goals?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260518190932.42270-1-maksym.shcherba@lnu.edu.ua?part=2

  reply	other threads:[~2026-05-18 19:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
2026-05-18 19:09 ` [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command Maksym Shcherba
2026-05-18 19:57   ` sashiko-bot [this message]
2026-05-19  0:17   ` SeongJae Park
2026-05-19  7:33     ` Maksym Shcherba
2026-05-19 15:08       ` SeongJae Park
2026-05-18 19:09 ` [PATCH 3/6] Docs/ABI/damon: document " Maksym Shcherba
2026-05-18 19:09 ` [PATCH 4/6] Docs/admin-guide/mm/damon/usage: document update_schemes_quota_goals sysfs command Maksym Shcherba
2026-05-18 19:09 ` [PATCH 5/6] selftests/damon/_damon_sysfs: support update_schemes_quota_goals Maksym Shcherba
2026-05-18 19:09 ` [PATCH 6/6] selftests/damon: add a test for update_schemes_quota_goals Maksym Shcherba
2026-05-19  0:10 ` [PATCH 1/6] mm/damon: fix missing parens in macro arguments 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=20260518195747.8CF14C2BCB7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=mshcherba2000@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox