[tip: sched/core] sched/cputime: Drop now-stale mul_u64_u64_div_u64() over-approximation guard

tip-bot2 for Nicolas Pitre posted 1 patch 4 days, 14 hours ago
kernel/sched/cputime.c | 6 ------
1 file changed, 6 deletions(-)
[tip: sched/core] sched/cputime: Drop now-stale mul_u64_u64_div_u64() over-approximation guard
Posted by tip-bot2 for Nicolas Pitre 4 days, 14 hours ago
The following commit has been merged into the sched/core branch of tip:

Commit-ID:     95f44886afec7cbce0ff2a5ed8158fbe8aa6f2ec
Gitweb:        https://git.kernel.org/tip/95f44886afec7cbce0ff2a5ed8158fbe8aa6f2ec
Author:        Nicolas Pitre <nico@fluxnic.net>
AuthorDate:    Thu, 14 May 2026 16:26:29 -04:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 19 May 2026 12:17:35 +02:00

sched/cputime: Drop now-stale mul_u64_u64_div_u64() over-approximation guard

Commit 77baa5bafcbe ("sched/cputime: Fix mul_u64_u64_div_u64() precision
for cputime") added a clamp in cputime_adjust():

	if (unlikely(stime > rtime))
		stime = rtime;

The justification was that mul_u64_u64_div_u64() could over-approximate
on some architectures (notably arm64 and the old 32-bit fallback), so
the mathematically impossible stime > rtime was nevertheless reachable
and would underflow utime = rtime - stime.

That premise no longer holds. Commit b29a62d87cc0 ("mul_u64_u64_div_u64:
make it precise always") replaced the fallback implementation with an
exact 128-bit long division, and the x86_64 inline asm already produced
exact results. The helper now returns the mathematically correct
floor(a*b/d) on every architecture, so stime <= rtime is guaranteed by
stime <= stime + utime and the clamp is dead code.

Remove it along with its stale comment.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260514202629.673539-1-nico@fluxnic.net
---
 kernel/sched/cputime.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index fbf31db..6e85023 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -587,12 +587,6 @@ void cputime_adjust(struct task_cputime *curr, struct prev_cputime *prev,
 	}
 
 	stime = mul_u64_u64_div_u64(stime, rtime, stime + utime);
-	/*
-	 * Because mul_u64_u64_div_u64() can approximate on some
-	 * achitectures; enforce the constraint that: a*b/(b+c) <= a.
-	 */
-	if (unlikely(stime > rtime))
-		stime = rtime;
 
 update:
 	/*