Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp758506imm; Wed, 19 Sep 2018 06:31:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZkD3mdxyM65vojcoN461e3yBosY45SRkh46pdDB/cRbes3QMZOpGQt0NTgyaBZBDStQy7B X-Received: by 2002:a62:59d5:: with SMTP id k82-v6mr35915211pfj.143.1537363887947; Wed, 19 Sep 2018 06:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537363887; cv=none; d=google.com; s=arc-20160816; b=EE3scsXAqV2ckSdFtxiCZAaNlHhoGWBH/7K5gBKEK6hCeHta0g49cdQzPzzhQRCspp JAQv3oCp+pb0p14KSYo/hmy9JwsV8kyYG/vydEYLEjFqYNL7DnoHG7ByOOojg0l1sBeP FQJ79zT0DNRF0UJAMa95ASA6wvAIvICZwATar7nuaDgc4p9jRW5bUZ6NEnhQskea8Sk1 Tx15Sp0klXefd9vy0EDybUm3fkeVwhO12rm6+Z2VruNrV/Ruats83MXSIBOfYhXKNyb0 aURNcHzvVRqo8eAur0MG95Y2P+ujvBMlLqqJc/wzS61zphQyfvUy95buKyUoThnhdoDJ QvPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=Q4aO0LhsrOQ+IQGTkOQvbs2dVH6KaTNbd7bGL6Os4l0=; b=Ub2qpOTkuQTmJOCNt/kwpBbL302gWt8xTFstIPd1J7heTIeYGJA3cKiuOUCCoKoJyC FArH6eOfkKl68zuOy9+E6CR3UJDEtoX3TZpipy+HwftislozU0VlXTsZ1FQVvdfuyqWy 1kHKUjdM+BbZvAFJpWjfx7XF/YsGXl9grJTvBTn0Vqqrwq/BAeAu/VyFlU2Ua7hSouFs kWlFQAJcaQPAJy2KT8FSz2O1DSHQpo+nB/u8DHpXgPoDHHOxAbeWuT9yGz4rKI9I1q+3 +nJjZ3K9lAg35V6ZTFVyIgavuhkw6Xxb/C+yJH256lWsvhJ8HqscFXD5ch+Z25mSYr0N rtFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h8-v6si24105415pli.14.2018.09.19.06.31.12; Wed, 19 Sep 2018 06:31:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732156AbeISTHl (ORCPT + 99 others); Wed, 19 Sep 2018 15:07:41 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:60771 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730876AbeISTHk (ORCPT ); Wed, 19 Sep 2018 15:07:40 -0400 Received: from hsi-kbw-5-158-153-55.hsi19.kabel-badenwuerttemberg.de ([5.158.153.55] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1g2cXv-0002im-Rx; Wed, 19 Sep 2018 15:29:36 +0200 Date: Wed, 19 Sep 2018 15:29:30 +0200 (CEST) From: Thomas Gleixner To: Rasmus Villemoes cc: Andy Lutomirski , John Stultz , Andy Lutomirski , LKML , X86 ML , Peter Zijlstra , Matt Rickard , Stephen Boyd , Florian Weimer , "K. Y. Srinivasan" , Vitaly Kuznetsov , devel@linuxdriverproject.org, Linux Virtualization , Paolo Bonzini , Arnd Bergmann , Juergen Gross Subject: Re: [patch 09/11] x86/vdso: Simplify the invalid vclock case In-Reply-To: <06e91c26-756f-f236-0af2-327e520c3065@rasmusvillemoes.dk> Message-ID: References: <20180914125006.349747096@linutronix.de> <20180914125118.909646643@linutronix.de> <863331ED-B04A-4B94-91A2-D34002C9CCDC@amacapital.net> <06e91c26-756f-f236-0af2-327e520c3065@rasmusvillemoes.dk> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1406624157-1537363775=:18945" 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1406624157-1537363775=:18945 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 19 Sep 2018, Rasmus Villemoes wrote: > On 2018-09-19 00:46, Thomas Gleixner wrote: > > On Tue, 18 Sep 2018, Andy Lutomirski wrote: > >>> > >> > >> Do we do better if we use signed arithmetic for the whole calculation? > >> Then a small backwards movement would result in a small backwards result. > >> Or we could offset everything so that we’d have to go back several > >> hundred ms before we cross zero. > > > > That would be probably the better solution as signed math would be > > problematic when the resulting ns value becomes negative. As the delta is > > really small, otherwise the TSC sync check would have caught it, the caller > > should never be able to observe time going backwards. > > > > I'll have a look into that. It needs some thought vs. the fractional part > > of the base time, but it should be not rocket science to get that > > correct. Famous last words... > > Does the sentinel need to be U64_MAX? What if vgetcyc and its minions > returned gtod->cycle_last-1 (for some value of 1), and the caller just > does "if ((s64)cycles - (s64)last < 0) return fallback; ns += > (cycles-last)* ...". That should just be a "sub ; js ; ". It's an extra > load of ->cycle_last, but only on the path where we're heading for the > fallback anyway. The value of 1 can be adjusted so that in the "js" > path, we could detect and accept an rdtsc_ordered() call that's just a > few 10s of cycles behind last and treat that as 0 and continue back on > the normal path. But maybe it's hard to get gcc to generate the expected > code. I played around with a lot of variants and GCC generates all kinds of interesting ASM. And at some point optimizing that math code is not buying anything because the LFENCE before RDTSC is dominating all of it. Thanks, tglx --8323329-1406624157-1537363775=:18945--