Skip to content

Commit 14c643e

Browse files
sjp38gregkh
authored andcommitted
mm/damon/core: use time_in_range_open() for damos quota window start
commit 049a574 upstream. damos_adjust_quota() uses time_after_eq() to show if it is time to start a new quota charge window, comparing the current jiffies and the scheduled next charge window start time. If it is, the next charge window start time is updated and the new charge window starts. The time check and next window start time update is skipped while the scheme is deactivated by the watermarks. Let's suppose the deactivation is kept more than LONG_MAX jiffies (assuming CONFIG_HZ of 250, more than 99 days in 32 bit systems and more than one billion years in 64 bit systems), resulting in having the jiffies larger than the next charge window start time + LONG_MAX. Then, the time_after_eq() call can return false until another LONG_MAX jiffies are passed. This means the scheme can continue working after being reactivated by the watermarks. But, soon, the quota will be exceeded and the scheme will again effectively stop working until the next charge window starts. Because the current charge window is extended to up to LONG_MAX jiffies, however, it will look like it stopped unexpectedly and indefinitely, from the user's perspective. Fix this by using !time_in_range_open() instead. The issue was discovered [1] by sashiko. Link: https://lore.kernel.org/20260329152306.45796-1-sj@kernel.org Link: https://lore.kernel.org/20260324040722.57944-1-sj@kernel.org [1] Fixes: ee801b7 ("mm/damon/schemes: activate schemes based on a watermarks mechanism") Signed-off-by: SeongJae Park <sj@kernel.org> Cc: <stable@vger.kernel.org> # 5.16.x Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d975c07 commit 14c643e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mm/damon/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,8 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
10481048
quota->charged_from = jiffies;
10491049

10501050
/* New charge window starts */
1051-
if (time_after_eq(jiffies, quota->charged_from +
1051+
if (!time_in_range_open(jiffies, quota->charged_from,
1052+
quota->charged_from +
10521053
msecs_to_jiffies(quota->reset_interval))) {
10531054
if (quota->esz && quota->charged_sz >= quota->esz)
10541055
s->stat.qt_exceeds++;

0 commit comments

Comments
 (0)