From: sashiko-bot@kernel.org
To: "Akinobu Mita" <akinobu.mita@gmail.com>
Cc: damon@lists.linux.dev, linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v3 1/4] mm/damon/core: add code borrowed from report-based monitoring work
Date: Thu, 23 Apr 2026 01:21:59 +0000 [thread overview]
Message-ID: <20260423012200.955F7C2BCB2@smtp.kernel.org> (raw)
In-Reply-To: <20260423004211.7037-2-akinobu.mita@gmail.com>
Sashiko AI review found 2 potential issue(s):
- [Medium] Stack bloat / stack overflow risk from `cpumask_t` allocation on the stack.
- [Medium] Data race and potential torn reads from lockless assignment of `cpumask_t`.
--
commit 9c32a9c6100e762865883bc9bf4b2272ccb6dedb
Author: Akinobu Mita <akinobu.mita@gmail.com>
mm/damon/core: add code borrowed from report-based monitoring work
This commit borrows code from the report-based monitoring infrastructure
to support perf event-based monitoring. It brings in struct
damon_access_report, an access_reported field in damon_region, and the
sample/primitives sysfs directory structure.
Link: https://lore.kernel.org/linux-mm/20251208062943.68824-6-sj@kernel.org/T/
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index eefa959aa30ae..c19556f2af3bb 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
[ ... ]
> +static ssize_t cpumask_store(struct kobject *kobj, struct kobj_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct damon_sysfs_sample_filter *filter = container_of(kobj,
> + struct damon_sysfs_sample_filter, kobj);
> + cpumask_t cpumask;
Is it safe to allocate cpumask_t on the stack here?
The size of cpumask_t scales with CONFIG_NR_CPUS. On systems with a large
number of CPUs, this could consume a significant amount of the kernel stack
and potentially risk a stack overflow. Should this use alloc_cpumask_var()
instead to dynamically allocate the temporary mask?
> + int err = cpulist_parse(buf, &cpumask);
> +
> + if (err)
> + return err;
> + filter->cpumask = cpumask;
Can this lockless assignment cause a data race or torn reads?
Because cpumask_t can be larger than a single word, this assignment may
compile into a non-atomic multi-word copy like memcpy(). If a concurrent
sysfs read in cpumask_show() or a DAMON commit operation accesses
filter->cpumask while this copy is ongoing, could it read a partially
updated, torn mask?
Should this be protected by explicit synchronization, such as
damon_sysfs_lock?
> + return count;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260423004211.7037-1-akinobu.mita@gmail.com?part=1
next prev parent reply other threads:[~2026-04-23 1:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 0:42 [RFC PATCH v3 0/4] mm/damon: introduce perf event based access check Akinobu Mita
2026-04-23 0:42 ` [RFC PATCH v3 1/4] mm/damon/core: add code borrowed from report-based monitoring work Akinobu Mita
2026-04-23 1:21 ` sashiko-bot [this message]
2026-04-23 0:42 ` [RFC PATCH v3 2/4] mm/damon/core: add common code for perf event based access check Akinobu Mita
2026-04-23 1:58 ` sashiko-bot
2026-04-23 0:42 ` [RFC PATCH v3 3/4] mm/damon/vaddr: support " Akinobu Mita
2026-04-23 2:48 ` sashiko-bot
2026-04-23 0:42 ` [RFC PATCH v3 4/4] mm/damon/paddr: " Akinobu Mita
2026-04-23 3:22 ` sashiko-bot
2026-04-23 4:34 ` [RFC PATCH v3 0/4] mm/damon: introduce " SeongJae Park
2026-04-24 3:27 ` Akinobu Mita
2026-04-24 23:31 ` SeongJae Park
2026-04-25 12:33 ` Akinobu Mita
2026-04-25 15:33 ` 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=20260423012200.955F7C2BCB2@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akinobu.mita@gmail.com \
--cc=damon@lists.linux.dev \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko@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