Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3304344imm; Fri, 19 Oct 2018 08:26:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63gSTUJbq5P8SX7WZPt2gS/qv2GM3Bn3e9MRgz6GIqxF1nqZz1kHCuuDJoGaB+ukL0TotbH X-Received: by 2002:a17:902:9896:: with SMTP id s22-v6mr33935636plp.113.1539962774491; Fri, 19 Oct 2018 08:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539962774; cv=none; d=google.com; s=arc-20160816; b=CvJ0yov4i5eY76HgoICUPbPRzE8bsm+UX1WnJnnSwwtjW4RknLBp1nvxQBvE9HC/26 ozF38EQPHFXVK9qPkDd9pq3g2sLrS0W1rc9b656cXUW6loe9olCYo33znKJtX9mL58Rw xjPqttN2KQRCZiM9MnDky3VESTy2NQVCfxSHGn/nsZGJH+pGKGgXoZe4LMu/klzTmCKB LOWqLUlRUGYh0o4z+PToT5h+F/z7U65XdW1ZVHIPg32cA8qAynJew+YZewE3FUwZRhH8 r9WsmbVuapLOeSmEdw5sEsoIWLThHCr3PXkHNMNzA+DgEFst+Rx3orZ6JYBcT8kXYvdE m3Fw== 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=X1nszxnzFUCuhyO+n828/Cc4Ks4IynumPDV7jCU/Ip0=; b=pNztLgQiXwMKp6akrp7N+7a7jnEjw1bztmKh42O62pJczOc7ghnHeTFOaqvL8pCv5+ uYL/Sbh3U581E5jokGznPxDXvUbmATcPIJQHAHQ5JsGDOudbu8z1jqiULZvsUEWKRLrf /saCozXuC+9BD2mabmHK0AX/TOaw0WjygWmXz+NM091fXnnVG/L5ALZskEGYkqzOuoEG iZk+TNlJUHo8wuvWvpVBCXNVu2yL0cXS0YIji23+fiuZKINjycR5vUR12hLf/QEEXaVw GU6s4OJrFrTF5TifJ+uKPHkEkWeyFvnJge1w7A2m5z9owsVyUxuOqYILYodtePfaajW/ 6UUA== 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 r13-v6si23820403pfb.43.2018.10.19.08.25.59; Fri, 19 Oct 2018 08:26:14 -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 S1727119AbeJSXcC (ORCPT + 99 others); Fri, 19 Oct 2018 19:32:02 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:39567 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726465AbeJSXcC (ORCPT ); Fri, 19 Oct 2018 19:32:02 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gDWe7-0001XP-6g; Fri, 19 Oct 2018 17:25:03 +0200 Date: Fri, 19 Oct 2018 17:25:02 +0200 (CEST) From: Thomas Gleixner To: Christopher Hall cc: "H. Peter Anvin" , linux-rt-users , jesus.sanchez-palencia@intel.com, gavin.hindman@intel.com, liam.r.girdwood@intel.com, Peter Zijlstra , LKML , John Stultz Subject: Re: TSC to Mono-raw Drift In-Reply-To: <20181015160945.5993-1-christopher.s.hall@intel.com> 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christopher, Please Cc LKML on such issues in the future. On Mon, 15 Oct 2018, Christopher Hall wrote: Leaving context around for new readers: > Problem Statement: > > The TSC clocksource mult/shift values are derived from CPUID[15H], but the > monotonic raw clock value is not equal to TSC in nominal nanoseconds, i.e. > the timekeeping code is not accurately transforming TSC ticks to nominal > nanoseconds based on CPUID[15H}. > > The included code calculates the drift between nominal TSC nanoseconds and > the monotonic raw clock. > > Background: > > Starting with 6th generation Intel CPUs, the TSC is "phase locked" to the > Always Running Timer (ART). The relation between TSC and ART is read from > CPUID[15H]. Details of the TSC-ART relation are in the "Invariant > Timekeeping" section of the SDM. > > CPUID[15H].ECX returns the nominal frequency of ART (or crystal frequency). > CPU feature TSC_KNOWN_FREQ indicates that tsc_khz (tsc.c) is derived from > CPUID[15H]. The calculation is in tsc.c:native_calibrate_tsc(). > > When the TSC clocksource is selected, the timekeeping code uses mult/shift > values to transform TSC into nanoseconds. The mult/shift value is determined > using tsc_khz. > > Example Output: > > Running for 3 seconds trial 1 > Scaled TSC delta: 3000328845 > Monotonic raw delta: 3000329117 > Ran for 3 seconds with 272 ns skew > > Running for 3 seconds trial 2 > Scaled TSC delta: 3000295209 > Monotonic raw delta: 3000295482 > Ran for 3 seconds with 273 ns skew > > Running for 3 seconds trial 3 > Scaled TSC delta: 3000262870 > Monotonic raw delta: 3000263142 > Ran for 3 seconds with 272 ns skew > > Running for 300 seconds trial 4 > Scaled TSC delta: 300000281725 > Monotonic raw delta: 300000308905 > Ran for 300 seconds with 27180 ns skew > > The skew between tsc and monotonic raw is about 91 PPB. > > System Information: > > CPU model string: Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz > Kernel version tested: 4.14.71-rt44 > NOTE: The skew seems to be insensitive to kernel version after > introduction of TSC_KNOWN_FREQ capability > > >From CPUID[15H]: > Time Stamp Counter/Core Crystal Clock Information (0x15): > TSC/clock ratio = 276/2 > nominal core crystal clock = 24000000 Hz (table lookup) > > 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? Thanks, Thomas