Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp489479imm; Wed, 19 Sep 2018 02:09:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbN21e+Aiv2iAF5vb2oRHl+KJJAWsyV8cfM4iIMSOo25gm9uuDrKtcWhVBpMNAZE02QYPyn X-Received: by 2002:a62:47d1:: with SMTP id p78-v6mr35121577pfi.197.1537348181106; Wed, 19 Sep 2018 02:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537348181; cv=none; d=google.com; s=arc-20160816; b=EhTPPdHEaHumH3t+Zs98+Lpdg4EbgP8FhQaCNrymWmIiQ0pJEQLJejKq1Ke4aQ3O+g SsjYPOPQMovA4/ue5bgNo1XPjVcwkGSf7BRuAZ/F3PbCgNQlZBdeLAYGSK7++l/3v1ac PN57Fm/XzBaSli5Wr/N5oXkHnUT7T1CKvHzDdgQ3MMNa3s96Ebr640slqol+xgVUoc3B qJ+5nZTw0aA+Bz1rQ7yoMBlV4O/iB7IJk2QDfl2sK/cVCXs1dW/Bh38/tcOxSqiIWmYv rm8VEJJAVcl1bClJ1ZzzIahlz6GvKOLiexRW5tubHupS/2PUBqgy9XRgVpCqNcw928E4 4X2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=dnUs+rHf+qRGsytFHQLej747GSU5gZGA2K/FGQBGvGs=; b=LhR0CurNCfDpzhZH50DfXDwUHNiEkgnlM3JfURe4vra/FMh1x8a+c2FC+6qvkZyHZ/ 2XqxvUPC/zXwintYTlHWJLlbtC8dBk76la3mhG5aBW+3hbGYGfWiDsV9oXwfwHB4dkTY j4I0d43hsFYfPPleO/l6DQ8i98gEm8y6LmGrB0phaJ5TkB0Y8JLGxmhMobKACos30S7d GtehLl9+bzep4kn5ARv2V1ndqkAYzHtW3afQCiEpJy+zv9RIL7rE4s5Ijzts4aiOTHip HGH67RYoMTJMb253dldWzg/yhJ85VaMuyllHdlc3ksxSpQyS1M8yvYl6f5XdG1tYlpuG xNbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="f/VEo/pB"; 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 n5-v6si20490895plp.186.2018.09.19.02.09.25; Wed, 19 Sep 2018 02:09:41 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="f/VEo/pB"; 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 S1731059AbeISOqA (ORCPT + 99 others); Wed, 19 Sep 2018 10:46:00 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36196 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbeISOqA (ORCPT ); Wed, 19 Sep 2018 10:46:00 -0400 Received: by mail-lf1-f68.google.com with SMTP id v17-v6so573880lfe.3 for ; Wed, 19 Sep 2018 02:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=dnUs+rHf+qRGsytFHQLej747GSU5gZGA2K/FGQBGvGs=; b=f/VEo/pB12IXPaBws3yeDH8MgD0sUoEyWuFsyQd+IrsfJvj0BJXyzvKlmq3XkcjYgM w50meoBzy2g6UjdOMnvGk7pYm+TNZejNBC3rJOMVjhC3WOmEU65E7mcPKksHjHVc4TZa jbh41K/wgOJgInAO9ZvBnN62RMw8B78yVKhrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dnUs+rHf+qRGsytFHQLej747GSU5gZGA2K/FGQBGvGs=; b=NQUzYs++NG64TSZ5WuHqgo4rjNthTiK5h1FLtrFBJbl+IKJemyOhPxP/sHMfZTIKUt 3zghIVrUJlgfHP3JC0JJUBdcDsMCUpsLxBx5VNOVrpdvqZg7+Oe5nQfYvtW4p94rB//b JZEU06zQqqPLYqxvF96vd5+asOZljjPlJi/pitET8AAArMvSqyo87s+zaql+n/z3kTlZ 5AfTh18gsrhU8S5jyP5V2GFnM6v5Ju76aVdcMWmwneQxEd+Zni4xeF0T2ErAH7BeAO6D jr/SgNk/5WuQJIezZ6YVQfIKKgXPY6kV+4WJJbB9ZHutHdgkto8gW0glIEofwz6Lb/qH 8hxg== X-Gm-Message-State: APzg51D/HOpXkliuQa16LMUsZO9xTzdj9YdK5O47boOR1kUGWLaKnU0v y0cNkPuh90zkDvcNy9Zfc6yPqg== X-Received: by 2002:a19:7391:: with SMTP id h17-v6mr9826598lfk.140.1537348140792; Wed, 19 Sep 2018 02:09:00 -0700 (PDT) Received: from [172.16.11.40] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id z5-v6sm946497lfg.75.2018.09.19.02.08.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 02:09:00 -0700 (PDT) Subject: Re: [patch 09/11] x86/vdso: Simplify the invalid vclock case To: Thomas Gleixner , Andy Lutomirski Cc: 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 References: <20180914125006.349747096@linutronix.de> <20180914125118.909646643@linutronix.de> <863331ED-B04A-4B94-91A2-D34002C9CCDC@amacapital.net> From: Rasmus Villemoes Message-ID: <06e91c26-756f-f236-0af2-327e520c3065@rasmusvillemoes.dk> Date: Wed, 19 Sep 2018 11:08:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Rasmus