From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Chancellor Subject: Re: [PATCH] vsyscall: use __iter_div_u64_rem() Date: Wed, 10 Jul 2019 09:56:51 -0700 Message-ID: <20190710165651.GA29814@archlinux-threadripper> References: <20190710130206.1670830-1-arnd@arndb.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190710130206.1670830-1-arnd@arndb.de> Sender: linux-kernel-owner@vger.kernel.org To: Arnd Bergmann Cc: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kselftest@vger.kernel.org, Catalin Marinas , Will Deacon , Russell King , Ralf Baechle , Paul Burton , Daniel Lezcano , Mark Salyzyn , Peter Collingbourne , Shuah Khan , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Huw Davies , linux-kernel@vger.kernel.org, clang-built-linux@googlegrou List-Id: linux-arch.vger.kernel.org On Wed, Jul 10, 2019 at 03:01:53PM +0200, Arnd Bergmann wrote: > 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 > --- > 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 > What an interesting function. Looks good to me and I can confirm it fixes the link error. Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com ([209.85.128.68]:50260 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727487AbfGJQ44 (ORCPT ); Wed, 10 Jul 2019 12:56:56 -0400 Date: Wed, 10 Jul 2019 09:56:51 -0700 From: Nathan Chancellor Subject: Re: [PATCH] vsyscall: use __iter_div_u64_rem() Message-ID: <20190710165651.GA29814@archlinux-threadripper> References: <20190710130206.1670830-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190710130206.1670830-1-arnd@arndb.de> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Arnd Bergmann Cc: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kselftest@vger.kernel.org, Catalin Marinas , Will Deacon , Russell King , Ralf Baechle , Paul Burton , Daniel Lezcano , Mark Salyzyn , Peter Collingbourne , Shuah Khan , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Huw Davies , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Message-ID: <20190710165651.Vq1Qaq5Jbu8o7DIrmmgAt2o5T9Z5VxFgben8Ba8FMWU@z> On Wed, Jul 10, 2019 at 03:01:53PM +0200, Arnd Bergmann wrote: > 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 > --- > 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 > What an interesting function. Looks good to me and I can confirm it fixes the link error. Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor