public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/damon/core: use time_in_range_open() for damos quota window start
@ 2026-03-29 15:23 SeongJae Park
  2026-03-29 15:48 ` (sashiko status) " SeongJae Park
  0 siblings, 1 reply; 2+ messages in thread
From: SeongJae Park @ 2026-03-29 15:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, # 5 . 16 . x, damon, linux-kernel, linux-mm

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.

[1] https://lore.kernel.org/20260324040722.57944-1-sj@kernel.org

Fixes: ee801b7dd782 ("mm/damon/schemes: activate schemes based on a watermarks mechanism")
Cc: <stable@vger.kernel.org> # 5.16.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Changes from RFC
(https://lore.kernel.org/20260328163930.47096-1-sj@kernel.org)
- Use time_in_range_open().
- Rebase to latest mm-new.

 mm/damon/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 19642c175568..3bc7a2bbfe7d 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2449,7 +2449,8 @@ 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_open(jiffies, quota->charged_from,
+				quota->charged_from +
 				msecs_to_jiffies(quota->reset_interval))) {
 		if (damos_quota_is_set(quota) &&
 				quota->charged_sz >= quota->esz)

base-commit: f7657f10211e1fca73ea2bc00d4b5ee938dbaa71
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: (sashiko status) [PATCH] mm/damon/core: use time_in_range_open() for damos quota window start
  2026-03-29 15:23 [PATCH] mm/damon/core: use time_in_range_open() for damos quota window start SeongJae Park
@ 2026-03-29 15:48 ` SeongJae Park
  0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2026-03-29 15:48 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, # 5 . 16 . x, damon, linux-kernel, linux-mm

Forwarding sashiko.dev review status for this thread.

# review url: https://sashiko.dev/#/patchset/20260329152306.45796-1-sj@kernel.org

- [PATCH] mm/damon/core: use time_in_range_open() for damos quota window start
  - status: Reviewed
  - review: No issues found.

# hkml [1] generated a draft of this mail.  It can be regenerated
# using below command:
#
#     hkml patch sashiko_dev --thread_status --for_forwarding \
#             20260329152306.45796-1-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail

Sent using hkml (https://github.com/sjp38/hackermail)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-29 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-29 15:23 [PATCH] mm/damon/core: use time_in_range_open() for damos quota window start SeongJae Park
2026-03-29 15:48 ` (sashiko status) " SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox