From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9367EC48BD6 for ; Tue, 25 Jun 2019 17:02:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73175205C9 for ; Tue, 25 Jun 2019 17:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728858AbfFYRCV (ORCPT ); Tue, 25 Jun 2019 13:02:21 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:44024 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727540AbfFYRCV (ORCPT ); Tue, 25 Jun 2019 13:02:21 -0400 Received: from p5b06daab.dip0.t-ipconnect.de ([91.6.218.171] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hfopi-0004Hb-GJ; Tue, 25 Jun 2019 19:02:14 +0200 Date: Tue, 25 Jun 2019 19:02:13 +0200 (CEST) From: Thomas Gleixner To: Vincenzo Frascino cc: linux-arch@vger.kernel.org, LAK , LKML , linux-mips@vger.kernel.org, linux-kselftest@vger.kernel.org, catalin.marinas@arm.com, Will Deacon , Arnd Bergmann , linux@armlinux.org.uk, Ralf Baechle , paul.burton@mips.com, Daniel Lezcano , salyzyn@android.com, pcc@google.com, shuah@kernel.org, 0x7f454c46@gmail.com, linux@rasmusvillemoes.dk, huw@codeweavers.com, sthotton@marvell.com, andre.przywara@arm.com, Andy Lutomirski Subject: Re: [PATCH 1/3] lib/vdso: Delay mask application in do_hres() In-Reply-To: <20190625161804.38713-1-vincenzo.frascino@arm.com> Message-ID: References: <20190624133607.GI29497@fuggles.cambridge.arm.com> <20190625161804.38713-1-vincenzo.frascino@arm.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On Tue, 25 Jun 2019, Vincenzo Frascino wrote: CC+ Andy > do_hres() in the vDSO generic library masks the hw counter value > immediately after reading it. > > Postpone the mask application after checking if the syscall fallback is > enabled, in order to be able to detect a possible fallback for the > architectures that have masks smaller than ULLONG_MAX. Right. This only worked on x86 because the mask is there ULLONG_MAX for all VDSO capable clocksources, i.e. that ever worked just by chance. As we talked about that already yesterday, I tested this on a couple of machines and as expected the outcome is uarch dependent. Minimal deviations to both sides and some machines do not show any change at all. I doubt it's possible to come up with a solution which makes all uarchs go faster magically. Though, thinking about it, we could remove the mask operation completely on X86. /me runs tests Thanks, tglx > Signed-off-by: Vincenzo Frascino > --- > lib/vdso/gettimeofday.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c > index ef28cc5d7bff..ee1221ba1d32 100644 > --- a/lib/vdso/gettimeofday.c > +++ b/lib/vdso/gettimeofday.c > @@ -35,12 +35,12 @@ static int do_hres(const struct vdso_data *vd, clockid_t clk, > > do { > seq = vdso_read_begin(vd); > - cycles = __arch_get_hw_counter(vd->clock_mode) & > - vd->mask; > + cycles = __arch_get_hw_counter(vd->clock_mode); > ns = vdso_ts->nsec; > last = vd->cycle_last; > if (unlikely((s64)cycles < 0)) > return clock_gettime_fallback(clk, ts); > + cycles &= vd->mask; > if (cycles > last) > ns += (cycles - last) * vd->mult; > ns >>= vd->shift; > -- > 2.22.0 > >