From: SeongJae Park <sj@kernel.org>
To: SeongJae Park <sj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: (sashiko review) [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files
Date: Sat, 4 Apr 2026 13:52:35 -0700 [thread overview]
Message-ID: <20260404205235.87148-1-sj@kernel.org> (raw)
In-Reply-To: <20260404163943.89278-3-sj@kernel.org>
sashiko found no real issue for this patch.
Forwarding sashiko review in a reply format with my inline
comments below, for details of my view and doing discussions
via mails if needed.
> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-3-sj@kernel.org
> # start of sashiko.dev inline review
> commit ee565644ac37e8bfceab5e62746d85906fb91b43
> Author: SeongJae Park <sj@kernel.org>
>
> mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files
>
> This commit implements the user-space ABI for the DAMOS action failed region
> quota-charge ratio setup. It adds two new sysfs files under the DAMON sysfs
> interface for DAMOS quotas, fail_charge_num and fail_charge_denom, which
> allow reading and setting the numerator and denominator of the failed regions
> charge ratio.
>
> > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> > index 5186966dafb35..d5bfba79f105f 100644
> > --- a/mm/damon/sysfs-schemes.c
> > +++ b/mm/damon/sysfs-schemes.c
>
> [ ... ]
>
> > @@ -1663,6 +1665,48 @@ static ssize_t goal_tuner_store(struct kobject *kobj,
> > return -EINVAL;
> > }
> >
> > +static ssize_t fail_charge_num_show(struct kobject *kobj,
> > + struct kobj_attribute *attr, char *buf)
> > +{
> > + struct damon_sysfs_quotas *quotas = container_of(kobj,
> > + struct damon_sysfs_quotas, kobj);
> > +
> > + return sysfs_emit(buf, "%u\n", quotas->fail_charge_num);
> > +}
> > +
> > +static ssize_t fail_charge_num_store(struct kobject *kobj,
> > + struct kobj_attribute *attr, const char *buf, size_t count)
> > +{
> > + struct damon_sysfs_quotas *quotas = container_of(kobj,
> > + struct damon_sysfs_quotas, kobj);
> > + int err = kstrtouint(buf, 0, "as->fail_charge_num);
> > +
> > + if (err)
> > + return -EINVAL;
>
> Could this lack of upper bounds checking lead to an integer overflow when
> the scheme is applied in the DAMON core?
>
> If a user provides a large value for fail_charge_num up to UINT_MAX, could the
> charge calculation in damos_apply_scheme():
>
> (sz - sz_applied) * quota->fail_charge_num / quota->fail_charge_denom
>
> overflow the unsigned long value?
>
> For example, on a 32-bit system, an unapplied region of just 5 MB multiplied
> by a user-supplied numerator of 1,000 yields over 5 billion, which exceeds
> the 32-bit maximum limit. On a 64-bit system, a 10 GB region multiplied by
> 4,000,000,000 would similarly overflow.
>
> When this overflow occurs, does the charged size wrap around to a very small
> value, causing the DAMOS action quota to be drastically undercharged and
> bypassing the user-defined limits?
That can happen, but shouldn't cause a real problem. Meanwhile, adding such
overflow check would make code unnecessarily complicated. I will keep this as
is. If it turns out this causes a real problem, we can consider making this
better documented or updating the code later, after the report is really made.
Thanks,
SJ
>
> > + return count;
> > +}
>
> [ ... ]
>
>
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-3-sj@kernel.org
# hkml [1] generated a draft of this mail. You can regenerate
# this using below command:
#
# hkml patch sashiko_dev --for_forwarding \
# 20260404163943.89278-3-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail
next prev parent reply other threads:[~2026-04-04 20:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 1/9] mm/damon/core: introduce " SeongJae Park
2026-04-04 20:46 ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files SeongJae Park
2026-04-04 20:52 ` SeongJae Park [this message]
2026-04-04 16:39 ` [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom} SeongJae Park
2026-04-04 20:58 ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files SeongJae Park
2026-04-04 21:01 ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 5/9] Docs/ABI/damon: document fail_charge_{num,denom} SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing SeongJae Park
2026-04-04 21:03 ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 7/9] selftets/damon/_damon_sysfs: support failed region quota charge ratio SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 8/9] selftests/damon/drgn_dump_damon_status: " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 9/9] selftets/damon/sysfs.py: test " SeongJae Park
2026-04-04 21:06 ` (sashiko status) [RFC PATCH 0/9] mm/damon: introduce DAMOS " 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=20260404205235.87148-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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.