]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/damon/core: use time_before() for next_apply_sis
authorSeongJae Park <sj@kernel.org>
Sat, 7 Mar 2026 19:49:13 +0000 (11:49 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:22 +0000 (13:53 -0700)
damon_ctx->passed_sample_intervals and damos->next_apply_sis are unsigned
long, and compared via normal comparison operators.  It is unsafe from
overflow.  Use time_before(), which is safe from overflow when correctly
used, instead.

Link: https://lkml.kernel.org/r/20260307194915.203169-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/core.c

index c8c2e4660b9867ab8ffee4d2cf0767aeabe57d4b..ac06465cd9eb4bc9581fb73bf2ce1cdf8079fffd 100644 (file)
@@ -2097,7 +2097,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
        damon_for_each_scheme(s, c) {
                struct damos_quota *quota = &s->quota;
 
-               if (c->passed_sample_intervals < s->next_apply_sis)
+               if (time_before(c->passed_sample_intervals, s->next_apply_sis))
                        continue;
 
                if (!s->wmarks.activated)
@@ -2455,7 +2455,7 @@ static void kdamond_apply_schemes(struct damon_ctx *c)
        bool has_schemes_to_apply = false;
 
        damon_for_each_scheme(s, c) {
-               if (c->passed_sample_intervals < s->next_apply_sis)
+               if (time_before(c->passed_sample_intervals, s->next_apply_sis))
                        continue;
 
                if (!s->wmarks.activated)
@@ -2479,7 +2479,7 @@ static void kdamond_apply_schemes(struct damon_ctx *c)
        }
 
        damon_for_each_scheme(s, c) {
-               if (c->passed_sample_intervals < s->next_apply_sis)
+               if (time_before(c->passed_sample_intervals, s->next_apply_sis))
                        continue;
                damos_walk_complete(c, s);
                damos_set_next_apply_sis(s, c);