Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1771567ima; Thu, 25 Oct 2018 04:50:50 -0700 (PDT) X-Google-Smtp-Source: AJdET5egdPpa7uVPd/4lemw9vwRmQ1R49ILpdoqGikDLREt4W0z+xr0Y4117yqlbwtfMHbl/7yzd X-Received: by 2002:a62:36c3:: with SMTP id d186-v6mr1198836pfa.133.1540468250011; Thu, 25 Oct 2018 04:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540468249; cv=none; d=google.com; s=arc-20160816; b=u0a9txz4my1q8Q/lgHbDkmYEpaWOsFwWJKVkmyVAwfJ6Iwpc/Zf/VH91uGnJQvvQl/ 5a7ftN+K445P+PQLI6+BGZrs25LeyJvWA47BYCd1EMPJoo5HdFLqWxJeS/s5P33FWEz5 /8WOvJGCgbkzERnmkWA6CkQnpxDB/J0bYjT7RNjIkEHM8pK02k5616hoGYho8OcJKIck j/JCsKTy816fXEqFVcMA+ltj7hACFAKBoPyRG7psIn49Xw9CYC+qh3KBtGkk7lqgdhlW SMal5QFkiecfEVw6LhDaADydI+aZ29QZ7aForW7mmHv+wzmFYjO6Egruw4Bj+O0nND/Y cnTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=RDTdM04RzYNt2gWhG1QyvtGXB+kKU9wbdXU6LQBAaAU=; b=sfEg3MAFtR5FiBW0ZrAQSBU0bBWYgGQ4cY6/zXpX8anY1fBIGKrm/Ky3zjzGTZ5MGp /Dtqsj0UclA1G0HySmk3wOLkblpiEjM3y5ofi9vHy2PDbW6n12z28PwXpin5pQ9E/3zh pTSoj5P/lf/Tcu+xBI7/nvhwQpqL9FY9gY6Tm1ZOUMynWdWDCIvUoEe7ETE1XDsHX+Fx Oy6O+TZ6Llrs++WpXt8cm3slsENuRz/ct4p/Bmvrl5/bJ8bxmIUzKQqLYqadYdfpMEUv EJ+0QS9NgU1iNvK9e65yjrBFzP1+rEA8gV2gWFv5CT8NBbKsKDUsaqFb5sidKopHwFET wD2g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9-v6si7857281pfh.232.2018.10.25.04.50.33; Thu, 25 Oct 2018 04:50:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727441AbeJYUWN (ORCPT + 99 others); Thu, 25 Oct 2018 16:22:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJYUWN (ORCPT ); Thu, 25 Oct 2018 16:22:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB6797DD26; Thu, 25 Oct 2018 11:49:47 +0000 (UTC) Received: from localhost (holly.tpb.lab.eng.brq.redhat.com [10.43.134.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A748A5DD6C; Thu, 25 Oct 2018 11:49:45 +0000 (UTC) Date: Thu, 25 Oct 2018 13:49:44 +0200 From: Miroslav Lichvar To: Christopher Hall Cc: John Stultz , Thomas Gleixner , "H. Peter Anvin" , linux-rt-users , jesus.sanchez-palencia@intel.com, Gavin Hindman , liam.r.girdwood@intel.com, Peter Zijlstra , LKML Subject: Re: TSC to Mono-raw Drift Message-ID: <20181025114944.GH12019@localhost> References: <20181024145113.GF12019@localhost> <20181024173248.GB6121@artvirt.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181024173248.GB6121@artvirt.jf.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 25 Oct 2018 11:49:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 24, 2018 at 01:32:48PM -0400, Christopher Hall wrote: > On Wed, Oct 24, 2018 at 04:51:13PM +0200, Miroslav Lichvar wrote: > > The error is too large to be corrected by stepping on clock updates. > > For a typical TSC frequency we have multiplier in the range of few > > millions, so that's a frequency error of up to few hundred ppb. In the > > For this example, a i5-6600 CPU @ 3.30GHz I measured 90 ppb. That is the > largest I've seen since measuring this on a few platforms. 20-40 PPB seems > more typical. It looks like there is rounding in the calculation of the multiplier, so for frequencies in the range of 3-5GHz the error will be up to about 149 ppb. Without rounding it would be twice as much, but always fast or slow. > > A better fix might be to modify the calculation of time to use a > > second multiplier, effectively increasing its resolution. However, > > I'm not sure, I'm understanding. Like cascading transforms? While this > would increase the precision, I think it would still drift over days. We > could probably fix up every second though. I was thinking about using a wider multiplier, but avoiding a full 64x64 bit multiplication. For example, in your case with the 3312MHz clock nsec = (cycles * 5065585) >> 24 could be replaced with nsec = (cycles * 5065584) >> 24 + (cycles * 4538763) >> 47 This would take few hours to drift by one nanosecond. If something like this was implemented for the raw clock, it would probably make sense to switch the other clocks too. > > that would slow down all users of the clock. > > Couldn't some clocksources specify an additional multiplier/precision and > others use lower precision? I guess it could, but I'm not sure if people here would be happy with the extra complexity. -- Miroslav Lichvar