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:01:54 EST
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.
Would using !time_in_range_open() preserve the exact original timing
semantics while still fixing the wrap-around stall issue?
> if (damos_quota_is_set(quota) &&
> quota->charged_sz >= quota->esz)
# end of sashiko.dev inline review
# review url: https://sashiko.dev/#/patchset/20260328163930.47096-1-sj@xxxxxxxxxx
#
# hkml [1] generated a draft of this mail. It can be regenerated
# using below command:
#
# hkml patch sashiko_dev --for_forwarding \
# 20260328163930.47096-1-sj@xxxxxxxxxx
#
# [1] https://github.com/sjp38/hackermail
Sent using hkml (https://github.com/sjp38/hackermail)