linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: SeongJae Park <sj@kernel.org>
Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: (sashiko review) [RFC PATCH v5.2 03/11] mm/damon/core: introduce failed region quota charge ratio
Date: Sun, 12 Apr 2026 11:07:53 -0700	[thread overview]
Message-ID: <20260412180754.84182-1-sj@kernel.org> (raw)
In-Reply-To: <20260412161957.82835-4-sj@kernel.org>

TL; DR: Sashiko found no blocker for this patch.  It is just asking a same
question that I decided to ignore.

Forwarding full sashiko review in a reply format with my inline comments below,
for sharing details of my view and doing followup discussions via mails if
needed.

> # review url: https://sashiko.dev/#/patchset/20260412161957.82835-4-sj@kernel.org
> # start of sashiko.dev inline review
> commit 45b2671ba02d19f0991caa536696cde623c0c081
> Author: SeongJae Park <sj@kernel.org>
> 
> mm/damon/core: introduce failed region quota charge ratio
> 
> This commit introduces a new DAMON core API for setting the charge ratio
> for action-failed memory. It allows specifying the ratio using a numerator
> and denominator to make charging fairer for successful vs failed actions.
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> > @@ -2041,6 +2043,23 @@ static void damos_walk_cancel(struct damon_ctx *ctx)
> >  	mutex_unlock(&ctx->walk_control_lock);
> >  }
> >  
> > +static void damos_charge_quota(struct damos_quota *quota,
> > +		unsigned long sz_region, unsigned long sz_applied)
> > +{
> > +	/*
> > +	 * sz_applied could be bigger than sz_region, depending on ops
> > +	 * implementation of the action, e.g., damos_pa_pageout().  Charge only
> > +	 * the region size in the case.
> > +	 */
> > +	if (!quota->fail_charge_denom || sz_applied > sz_region)
> > +		quota->charged_sz += sz_region;
> > +	else
> > +		quota->charged_sz += sz_applied + mult_frac(
> > +				(sz_region - sz_applied),
> > +				quota->fail_charge_num,
> > +				quota->fail_charge_denom);
> 
> Can this calculation overflow during the mult_frac() expansion?
> 
> The mult_frac(x, numer, denom) macro evaluates to:
> (x / denom * numer) + ((x % denom * numer) / denom)
> 
> Since both sz_region and sz_applied are unsigned long, on 32-bit systems this
> is a 32-bit type. If fail_charge_num is large, couldn't the remainder
> multiplication (or even the quotient multiplication) overflow unsigned long
> and truncate the size added to quota->charged_sz?

A question that same to what raised previously.  I decided to keep this as is
in favor of code simplicity, unless other humans make some voices.

> 
> > +}
> > +
> 
> 
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260412161957.82835-4-sj@kernel.org

Thanks,
SJ

# hkml [1] generated a draft of this mail.  You can regenerate
# this using below command:
#
#     hkml patch sashiko_dev --for_forwarding \
#             20260412161957.82835-4-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail


  reply	other threads:[~2026-04-12 18:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-12 16:19 [RFC PATCH v5.2 00/11] mm/damon: introduce DAMOS " SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 01/11] mm/damon/core: handle <min_region_sz remaining quota as empty SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 02/11] mm/damon/core: merge regions after applying DAMOS schemes SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 03/11] mm/damon/core: introduce failed region quota charge ratio SeongJae Park
2026-04-12 18:07   ` SeongJae Park [this message]
2026-04-12 16:19 ` [RFC PATCH v5.2 04/11] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 05/11] Docs/mm/damon/design: document fail_charge_{num,denom} SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 06/11] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 07/11] Docs/ABI/damon: document fail_charge_{num,denom} SeongJae Park
2026-04-12 18:10   ` (sashiko review) " SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 08/11] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 09/11] selftests/damon/_damon_sysfs: support failed region quota charge ratio SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 10/11] selftests/damon/drgn_dump_damon_status: " SeongJae Park
2026-04-12 16:19 ` [RFC PATCH v5.2 11/11] selftests/damon/sysfs.py: test " SeongJae Park
2026-04-12 18:14 ` (sashiko status) [RFC PATCH v5.2 00/11] 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=20260412180754.84182-1-sj@kernel.org \
    --to=sj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox