Re: (sashiko review) [RFC PATCH] mm/damon/core: use time_in_range() for damos quota window start
From: SeongJae Park
Date: Sat Mar 28 2026 - 13:03:34 EST
On Sat, 28 Mar 2026 10:00:08 -0700 SeongJae Park <sj@xxxxxxxxxx> wrote:
> Forwarding Sashiko review for doing discussions via mails.
>
> # review url: https://sashiko.dev/#/patchset/20260328163930.47096-1-sj@xxxxxxxxxx
> # start of sashiko.dev inline review
> commit 2ee07f5a4fcf25b39aeac61c6b88fe3fdfd0c9b6
> Author: SeongJae Park <sj@xxxxxxxxxx>
>
> mm/damon/core: use time_in_range() for damos quota window start
>
> This commit attempts to fix a stall in DAMOS quota charge windows when
> a scheme is deactivated for more than LONG_MAX jiffies. It replaces
> time_after_eq() with !time_in_range() to properly handle the extended
> time wrap-around.
>
> Link: https://lore.kernel.org/20260324040722.57944-1-sj@xxxxxxxxxx
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index db6c67e52d2b..8e47183473d3 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> > @@ -2452,7 +2452,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
> > }
> >
> > /* New charge window starts */
> > - if (time_after_eq(jiffies, quota->charged_from +
> > + if (!time_in_range(jiffies, quota->charged_from, quota->charged_from +
> > msecs_to_jiffies(quota->reset_interval))) {
>
> Does this introduce an off-by-one regression that extends every quota charge
> window by 1 jiffy?
>
> time_in_range(a, b, c) evaluates the inclusive interval [b, c], which means
> it returns true when jiffies exactly equals the end of the interval. The
> original code used time_after_eq(), which correctly triggered the new
> charge window exactly on that jiffy.
>
> By replacing it with !time_in_range(), the reset evaluates to false on that
> exact jiffy and is delayed until the next jiffy. For small reset_interval
> configurations or low CONFIG_HZ values, this 1-jiffy delay might alter the
> effective quota replenishment rate.
The effect should be negligible, but good finding.
>
> Would using !time_in_range_open() preserve the exact original timing
> semantics while still fixing the wrap-around stall issue?
Good suggestion, I will do so in the next revision.
Thanks,
SJ
[...]