Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3618788imm; Fri, 19 Oct 2018 13:51:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV62+CurEyUHSODlYVUgyFgsNEuatCEbP6gQB2IFwUuMlGkVB2vXomXD7oLmIMjIAtpayeg1R X-Received: by 2002:a63:7b5c:: with SMTP id k28-v6mr6429287pgn.385.1539982289257; Fri, 19 Oct 2018 13:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539982289; cv=none; d=google.com; s=arc-20160816; b=hnfKKTQ8DmuFG9MjBfR9UYVUL1ys9bsQlCKBmB4W6QaHGqfk8hkkShyd3mszShdR5v f/mJ9cjoHDgbqeBzndVac3XRRlVS/hJYcZZA8q5lyxFyfG/QhMvfbSuA0IlzlsEEdOM8 cxojktFCYePO5Nyb/boVkdO26DVNM+tU5b+VQm6O29tsipNW0Wm4DuIJWYzLj2cpHdY5 mZ0sThih/lsOmJ89LhsbrkPScQqjroBx7YAlAW78urgaxa8gx0fOScWlQe9LuTlzPDwv 1V7GefNF/L84Y2O97pd13AIYBYhKO6u1xq6a78WFKh2tes3oCxAWqaYbeM7U+iZlQyF0 3PMQ== 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=/JGmcuMySO5f6UP+UgzVwLk1QCQFdFEZfhZwKHqYj14=; b=ZagfojARs9Qusj6AUysrSGoQ82HpZZ34FNRZDIgEF0WoCXQ9YErBsOYBm9Syp+Lv0L ooyOlSgWeOO/tXTykCcAzVxa0moXqoIyjN/EOO4Z/1Y4yKpsMZlOHmnimCrYndVOQ/vW GrvydQMmLPHAv2ruDD4aR4VjsB4n7F0JuKOQ5Xj2gUA3NXU1ebUoVt7ouENvmskuWsxn Dy//Ximuibkeup9ONw6Cni2D1ecfH4JGlChEsyB/zp153A3Wa2zHIeM1zMa5/LyZQaga a74qEpVKtxvGRI/ZjDaul4HzHCh//4wdkqV0uamWwBiTHKqVPrk628vf4aZre/dfnm2+ NHrw== 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 v3-v6si26513585pfd.125.2018.10.19.13.51.14; Fri, 19 Oct 2018 13:51:29 -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 S1727503AbeJTE6F (ORCPT + 99 others); Sat, 20 Oct 2018 00:58:05 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:40216 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbeJTE6E (ORCPT ); Sat, 20 Oct 2018 00:58:04 -0400 Received: from p5492fe24.dip0.t-ipconnect.de ([84.146.254.36] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gDbic-00065n-4e; Fri, 19 Oct 2018 22:50:02 +0200 Date: Fri, 19 Oct 2018 22:50:01 +0200 (CEST) From: Thomas Gleixner To: John Stultz cc: Christopher Hall , "H. Peter Anvin" , linux-rt-users , jesus.sanchez-palencia@intel.com, gavin.hindman@intel.com, liam.r.girdwood@intel.com, Peter Zijlstra , LKML Subject: Re: TSC to Mono-raw Drift In-Reply-To: Message-ID: References: <20181015160945.5993-1-christopher.s.hall@intel.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org John, On Fri, 19 Oct 2018, John Stultz wrote: > On Fri, Oct 19, 2018 at 11:57 AM, Thomas Gleixner wrote: > > I don't think you need complex oscillation for that. The error is constant > > and small enough that it is a fractional nanoseconds thing with an interval > > <= 1s. So you can just add that in a regular interval. Due to it being > > small you can't observe time jumping I think. > > Well, from the examples the trouble is we seem to be a bit fast, > rather then slow. > So we'll have to reduce mult by one, and rework the calculations, but > maybe something like this (correcting the raw_interval value) would > work. Shouldn't be rocket science. It's a one off calculation of adjustment value and maybe the period at which the correction happens. > But this also sort of breaks, fundamental argument that the raw clock > is a simple mult/shift transformation of the underlying clocksource > counter. Its not the accuracy of the clock but the consistency that > was key. > > The counter argument is that the raw clock is abstracting the > underlying hardware so folks who would have used the TSC directly can > now use the raw clock and have a generic abstracted hardware-counter > interface. So userland shouldn't really be worried about the > occasional injections made since they shouldn't be trying to > re-generate the abstraction from the hardware themselves. <-- > Remember this point as we move to the next comment:) > > > The end-result is 'correct' as much correct it is in relation to real > > nanoseconds. :) > > > >> I guess I'd want to understand more of the use here and the need to > >> tie the raw clock back to the hardware counter it abstracts. > > > > The problem there is ART which is distributed to PCIe devices and ART time > > stamps are exposed in various ways. ART has a fixed ratio vs. TSC so there > > is a reasonable expectation that MONOTONIC_RAW is accurate. > > Which is maybe sort of my issue here. The raw clock provided a > abstraction away from the hardware for generic usage, but then its > being re-used with other un-abstracted hardware references. So unless > they use the same method of transformation, there will be problems (of > varying degree). OTOH. If people use the CPUID provided frequency information and the TSC from userspace then they get different results which is contrary to the goal of providing them an abstracted way of doing it. > We might be able to reduce the degree in this case, but I worry the > extra complexity may only cause problems for others. Is it really that complex to add a fixed correction value periodically? I don't think so and it should just work for any clocksource which is exposed this way. Famous last words ..... Thanks, tglx