Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3518942imm; Fri, 19 Oct 2018 11:59:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV62wfY2hjsO2XGRz/I/v7i+X2g5rzT/nnY3YZFrzXo5M9MR7+D+LPb6snXtvaGxdtlYFg1+W X-Received: by 2002:a63:121b:: with SMTP id h27-v6mr3533729pgl.120.1539975573204; Fri, 19 Oct 2018 11:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539975573; cv=none; d=google.com; s=arc-20160816; b=ArJ+OapqIJ4bZHqdURRjqgsmDQC7iZdzl0pdtg8eQv0pvodvzZs922CAjQCJf4fYWt lppPqcj3dHFkcLvWW2jhnQN8rTsc/nfZOMby9mudC/tjdHKMAu2RSmJxbcSIR/DiYJ1X Z0G/MyrhHV+fQGIMhN0STeoqlOB73MwSESxwzPkSuMijOdauU0zvr+evFbSNgGQQVQAY x4ZbBoLj7tF1242soRu5oUGUB7aA7+EQLMkJgXl1leuHT0CMU0ItskxEH57b+VpPRq6a 8zOvMgRIwQAwlwQBjJvB1Pg1bzKcWxeFqi+iKECMafEJedhyhAOuzia2FYEKjEgTVfHu ClsQ== 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=E8QTq0wD61VSgm5iruoXrv3ew7qk0HDslLqtckQdFII=; b=Rtf2+4Oz+ATB1dkI97QtDF+4eAG3u7hWBl6fEmAD4tMBe7nYhrqABuhRw7B9YUyx0K qNPLl+IGfw9NP8YiDuzXuRfRKMbAQVc0ossRULF3//tsHm33tMsSTer5mxj98HIqUAAm hNQSQztCfZiVI0dCYAe9s1ofXt5nFR3LBIMfD9T9z1Oc1aFq1LEMIip+x4lqJ8ZJNgSB ld74la/6T2N7BVllWvdVDcXxWwSOnCl5tW2YUOvI6jqMaPfggcF0t+7JlkWd84whjdoQ QlR4Mvub1qjnU2RU3LfaaKui/qAxIq9oBw3jRbMtwVZy0gsUlNKlT21xoJN+YhV5knPJ FyPw== 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 p8-v6si25704415plq.136.2018.10.19.11.59.17; Fri, 19 Oct 2018 11:59:33 -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 S1727784AbeJTDE7 (ORCPT + 99 others); Fri, 19 Oct 2018 23:04:59 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:40049 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727329AbeJTDE7 (ORCPT ); Fri, 19 Oct 2018 23:04:59 -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 1gDZxW-0004hY-HS; Fri, 19 Oct 2018 20:57:18 +0200 Date: Fri, 19 Oct 2018 20:57:18 +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 On Fri, 19 Oct 2018, John Stultz wrote: > On Fri, Oct 19, 2018 at 11:37 AM, Thomas Gleixner wrote: > > On Fri, 19 Oct 2018, Thomas Gleixner wrote: > >> On Mon, 15 Oct 2018, Christopher Hall wrote: > >> > TSC kHz used to calculate mult/shift value: 3312000 > >> > >> Now the most interesting information here would be the resulting mult/shift > >> value which the kernel uses. Can you please provide that? > > > > But aside of the actual values it's pretty obvious why this happens. It's a > > simple rounding error. Minimal, but still. To avoid rounding errors you'd > > have to find mult and shift values which exactly result in: > > > > (freq * mult) >> shift = 1e9 > > > > which is impossible for freq = 3312 * 1e6. > > Right. > > > A possible fix for this is, because the error is in the low PPB range, to > > adjust the error once per second or in some other sensible regular > > interval. > > Ehh.. I mean, this is basically what all the complicated ntp_error > logic does for the long-term accuracy compensation. Part of the > allure of the raw clock is that there is no changes made over time. > Its a very simple constant calculation. > > We could try to do something like pre-seed the ntpinterval value so > the default ntp_tick value corrects for this, but that's only going to > effect the monotonic/realtime clock until ntpd or anyone else sets a > different interval rate. > > So I'm not particularly eager in trying to do the type of small > frequency oscillation we do for monotonic/realtime for long-term > accuracy to the raw clock as that feels a bit antithetical to the > point of the raw clock. 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. 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. Thanks, tglx