From: SeongJae Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SeongJae Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [RFC PATCH v1.2 13/17] mm/damon/core: remove attrs param from damon_update_region_access_rate()
Date: Sun, 21 Jun 2026 13:40:49 -0700 [thread overview]
Message-ID: <20260621204050.10993-1-sj@kernel.org> (raw)
In-Reply-To: <20260621161456.F23981F000E9@smtp.kernel.org>
On Sun, 21 Jun 2026 16:14:56 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] Unprotected static local variables in access check functions cause cross-thread data races and cross-context access measurement pollution.
> --
>
> commit cc8a115fada6e1595d5b8a6c2e994e38ac982a9c
> Author: SeongJae Park <sj@kernel.org>
>
> mm/damon/core: remove attrs param from damon_update_region_access_rate()
>
> This commit removes the unused attrs parameter from
> damon_update_region_access_rate() and updates callers in the core,
> physical address, and virtual address monitoring code to match the new
> signature.
>
> [ ... ]
> > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
> > index d0598f5f26882..db48ad274b078 100644
> > --- a/mm/damon/paddr.c
> > +++ b/mm/damon/paddr.c
> > @@ -93,12 +93,12 @@ static void __damon_pa_check_access(struct damon_region *r,
> > /* If the region is in the last checked page, reuse the result */
> > if (ALIGN_DOWN(last_addr, last_folio_sz) ==
> > ALIGN_DOWN(sampling_addr, last_folio_sz)) {
> > - damon_update_region_access_rate(r, last_accessed, attrs);
> > + damon_update_region_access_rate(r, last_accessed);
>
> [Severity: High]
> This is a pre-existing issue, but does relying on last_accessed here cause
> data races when multiple kdamond threads run concurrently?
>
> In __damon_pa_check_access(), last_addr, last_folio_sz, and last_accessed
> are defined as static variables. Because they are shared globally across all
> concurrent damon contexts without synchronization, multiple kdamond threads
> will read and write them simultaneously.
>
> Could this allow one thread to incorrectly reuse a last_accessed result
> generated by a completely different thread monitoring a different physical
> region, corrupting the measurement accuracy?
Nice finding. Not a blocker of this patch, though. I will separatelly work on
this.
>
> > return;
> > }
>
> [ ... ]
> > diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> > index d271476035641..2e12cc628fea0 100644
> > --- a/mm/damon/vaddr.c
> > +++ b/mm/damon/vaddr.c
> > @@ -503,19 +503,19 @@ static void __damon_va_check_access(struct mm_struct *mm,
> > static bool last_accessed;
>
> [Severity: High]
> This isn't a bug introduced by this patch, but this static variable shares the
> same cross-thread data race issue as the physical address check.
>
> If multiple contexts are monitoring different processes, they will write to
> these variables simultaneously.
>
> Does this data race allow one kdamond thread to accidentally reuse the
> last_accessed result from another thread, breaking context isolation?
Ditto.
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-06-21 20:41 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-21 15:56 [RFC PATCH v1.2 00/17] mm/damon: optimize out nr_accesses_bp SeongJae Park
2026-06-21 15:56 ` [RFC PATCH v1.2 01/17] mm/damon: introduce damon_nr_accesses_mvsum() SeongJae Park
2026-06-21 16:10 ` sashiko-bot
2026-06-21 20:01 ` SeongJae Park
2026-06-21 15:56 ` [RFC PATCH v1.2 02/17] mm/damon/tests/core-kunit: test damon_mvsum() SeongJae Park
2026-06-21 15:56 ` [RFC PATCH v1.2 03/17] mm/damon/core: always update ->last_nr_accesses for intervals change SeongJae Park
2026-06-21 16:11 ` sashiko-bot
2026-06-21 20:23 ` SeongJae Park
2026-06-21 21:13 ` SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 04/17] mm/damon/core: use damon_nr_accesses_mvsum() in __damos_valid_target() SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 05/17] mm/damon/core: use damon_nr_accesses_mvsum() for damos region tracing SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 06/17] mm/damon/sysfs-schemes: use damon_nr_accesses_mvsum() for damo regions SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 07/17] mm/damon/core: remove damon_warn_fix_nr_accesses_corruption() SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 08/17] mm/damon/core: remove damon_verify_reset_aggregated() SeongJae Park
2026-06-21 16:06 ` sashiko-bot
2026-06-21 20:24 ` SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 09/17] mm/damon/core: remove damon_verify_merge_regions_of() SeongJae Park
2026-06-21 18:09 ` sashiko-bot
2026-06-21 20:35 ` SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 10/17] mm/damon/tests/core-kunit: remove nr_accesses_bp setup and tests SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 11/17] selftests/damon/drgn_dump_damon_status: do not dump nr_accesses_bp SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 12/17] mm/damon/core: remove nr_accesses_bp setups and updates SeongJae Park
2026-06-21 18:10 ` sashiko-bot
2026-06-21 20:37 ` SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 13/17] mm/damon/core: remove attrs param from damon_update_region_access_rate() SeongJae Park
2026-06-21 16:14 ` sashiko-bot
2026-06-21 20:40 ` SeongJae Park [this message]
2026-06-21 15:57 ` [RFC PATCH v1.2 14/17] mm/damonn/paddr: remove attrs param from __damon_pa_check_access() SeongJae Park
2026-06-21 16:07 ` sashiko-bot
2026-06-21 20:42 ` SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 15/17] mm/damon/vaddr: remove attrs param from __damon_va_check_access() SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 16/17] mm/damon/core: remove damon_moving_sum() and its unit test SeongJae Park
2026-06-21 15:57 ` [RFC PATCH v1.2 17/17] mm/damon: remove damon_region->nr_accesses_bp 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=20260621204050.10993-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-bot@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