mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] timekeeping: improve arithmetic divisions
@ 2020-01-03 15:55 Wen Yang
  0 siblings, 0 replies; only message in thread
From: Wen Yang @ 2020-01-03 15:55 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner, Stephen Boyd; +Cc: Wen Yang, linux-kernel

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.

Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-kernel@vger.kernel.org
---
 kernel/time/timekeeping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index ca69290..bad76c1 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -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;
 }
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-03 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-03 15:55 [PATCH] timekeeping: improve arithmetic divisions Wen Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®