[RFC PATCH v2 03/10] mm/damon/core: use mult_frac() in damon_feed_loop_next_input()
From: SJ Park
Date: Thu Sep 17 2026 - 00:06:35 EST
damon_feed_loop_next_input() does its best effort overflow protection.
score_goal_diff is always smaller than goal (10,000). Hence the
calculation can be replaced to use mult_frac() without concerning the
overflow. Use mult_frac().
Signed-off-by: SJ Park <sj@xxxxxxxxxx>
---
mm/damon/core.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 0299729e79ed9..7bbbd44379301 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2928,11 +2928,7 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input,
return min_input;
score_goal_diff = abs_diff(score, goal);
-
- if (last_input < ULONG_MAX / score_goal_diff)
- compensation = last_input * score_goal_diff / goal;
- else
- compensation = last_input / goal * score_goal_diff;
+ compensation = mult_frac(last_input, score_goal_diff, goal);
if (over_achieving)
return max(last_input - compensation, min_input);
--
2.47.3