[RFC PATCH 3/9] mm/damon/core: use mult_frac() in damon_feed_loop_next_input()

From: SJ Park

Date: Sat Sep 12 2026 - 16:09:12 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 61bb25674cd23..cf10f6d725c19 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2921,11 +2921,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