linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vsyscall: use __iter_div_u64_rem()
@ 2019-07-10 13:01 Arnd Bergmann
  2019-07-10 15:22 ` [tip:timers/urgent] timekeeping/vsyscall: Use __iter_div_u64_rem() tip-bot for Arnd Bergmann
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Arnd Bergmann @ 2019-07-10 13:01 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: Arnd Bergmann, linux-arch, linux-arm-kernel, linux-mips,
	linux-kselftest, Catalin Marinas, Will Deacon, Russell King,
	Ralf Baechle, Paul Burton, Daniel Lezcano, Mark Salyzyn,
	Peter Collingbourne, Shuah Khan, Dmitry Safonov,
	Rasmus Villemoes, Huw Davies, linux-kernel, clang-built-linux

On 32-bit x86 when building with clang-9, the loop gets turned back into
an inefficient division that causes a link error:

kernel/time/vsyscall.o: In function `update_vsyscall':
vsyscall.c:(.text+0xe3): undefined reference to `__udivdi3'

Use the provided __iter_div_u64_rem() function that is meant to address
the same case in other files.

Fixes: 44f57d788e7d ("timekeeping: Provide a generic update_vsyscall() implementation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/time/vsyscall.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c
index a80893180826..8cf3596a4ce6 100644
--- a/kernel/time/vsyscall.c
+++ b/kernel/time/vsyscall.c
@@ -104,11 +104,7 @@ void update_vsyscall(struct timekeeper *tk)
 	vdso_ts->sec	= tk->xtime_sec + tk->wall_to_monotonic.tv_sec;
 	nsec		= tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift;
 	nsec		= nsec + tk->wall_to_monotonic.tv_nsec;
-	while (nsec >= NSEC_PER_SEC) {
-		nsec = nsec - NSEC_PER_SEC;
-		vdso_ts->sec++;
-	}
-	vdso_ts->nsec	= nsec;
+	vdso_ts->sec	+= __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec);
 
 	if (__arch_use_vsyscall(vdata))
 		update_vdso_data(vdata, tk);
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-07-22 10:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10 13:01 [PATCH] vsyscall: use __iter_div_u64_rem() Arnd Bergmann
2019-07-10 15:22 ` [tip:timers/urgent] timekeeping/vsyscall: Use __iter_div_u64_rem() tip-bot for Arnd Bergmann
2019-07-10 16:56 ` [PATCH] vsyscall: use __iter_div_u64_rem() Nathan Chancellor
2019-07-10 18:43 ` [tip:timers/urgent] timekeeping/vsyscall: Use __iter_div_u64_rem() tip-bot for Arnd Bergmann
2019-07-11 12:14 ` [PATCH] vsyscall: use __iter_div_u64_rem() Vincenzo Frascino
2019-07-11 12:28   ` Arnd Bergmann
2019-07-11 13:08     ` Vincenzo Frascino
2019-07-11 17:14     ` Nick Desaulniers
2019-07-11 20:55       ` Arnd Bergmann
2019-07-22 10:10     ` Thomas Gleixner
2019-07-22 10:38       ` Jan Beulich
2019-07-22 10:48         ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).