Skip to contentSkip to conversation

timekeeping: improve arithmetic divisions

PATCH New Wen Yang 1 participant 1 message Jan 3, 2020 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore

Wen Yang

author
#0 lore raw

PATCH 1/1 timekeeping: improve arithmetic divisions

do_div() does a 64-by-32 division. Use div64_u64() instead of do_div() if the divisor is u64, to avoid truncation to 32-bit.

Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Stephen Boyd <[email protected]>
---
 kernel/time/timekeeping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/timekeeping.c +1 -1
index ca69290..bad76c1 100644
@@ -1007,7 +1007,7 @@ static int scale64_check_overflow(u64 mult, u64 div, u64 *base)
 	tmp *= mult;
 	rem *= mult;
 
-	do_div(rem, div);
+	rem = div64_u64(rem, div);
 	*base = tmp + rem;
 	return 0;
 }
Signature · 1 line
1.8.3.1