Re: (sashiko review) [RFC PATCH v5 01/11] mm/damon/core: handle <min_region_sz remaining quota as empty

From: SeongJae Park

Date: Fri Apr 10 2026 - 19:32:34 EST


TL; DR: sashiko found a good finding that better to be done as a separate
cleanup work. This patch still seems good to go as-is.

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/20260410142034.83798-2-sj@xxxxxxxxxx
> # start of sashiko.dev inline review
> commit 2ab7d52b1eb10efa95d43a8eee7c50fd9669d56d
> Author: SeongJae Park <sj@xxxxxxxxxx>
>
> mm/damon/core: handle <min_region_sz remaining quota as empty
>
> This commit updates the core DAMOS logic to consider a quota fully charged
> if the remaining quota is less than the minimum region size. This prevents
> actions from being applied too frequently to specific memory areas.
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 12544c60531d3..8dbc365bb8e97 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
>
> [ ... ]
>
> > @@ -2127,8 +2140,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
> > continue;
> >
> > /* Check the quota */
> > - if (damos_quota_is_set(quota) &&
> > - quota->charged_sz >= quota->esz)
> > + if (damos_quota_is_full(quota, c->min_region_sz))
> > continue;
> >
> > if (damos_skip_charged_region(t, r, s, c->min_region_sz))
>
> With this new check skipping regions when the remaining quota is less than
> the minimum region size, does the truncation check in damos_apply_scheme()
> become unreachable?
>
> Because damon_do_apply_schemes() will now only call damos_apply_scheme()
> when quota->esz - quota->charged_sz >= c->min_region_sz, the ALIGN_DOWN
> calculation:
>
> damos_apply_scheme() {
> ...
> if (c->ops.apply_scheme) {
> if (damos_quota_is_set(quota) &&
> quota->charged_sz + sz > quota->esz) {
> sz = ALIGN_DOWN(quota->esz - quota->charged_sz,
> c->min_region_sz);
> if (!sz)
> goto update_stat;
> ...
> }
>
> will always result in a value greater than or equal to c->min_region_sz.
>
> Could the if (!sz) check and the corresponding goto update_stat be safely
> removed since sz can no longer evaluate to 0?

Good finding, but doing that would better to be a separate cleanup work. I
will add that to my todo list, but keep this patch as is.

>
>
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260410142034.83798-2-sj@xxxxxxxxxx

Thanks,
SJ

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