Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2826789imu; Sun, 23 Dec 2018 08:39:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/VkkLlVYia8uVQAYm0FZfU2lM4PkW5ioUDaAUjzmvB4u/kbLeaSrsAilZQQkgSw0nU6ZWDz X-Received: by 2002:a24:80d2:: with SMTP id g201mr7005716itd.63.1545583178613; Sun, 23 Dec 2018 08:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545583178; cv=none; d=google.com; s=arc-20160816; b=YgEC5pXPP+9q8V4wx60i5/m8LlNxND3Y6oXBzj0bSPtvEUOGE24zRLuO+EFGpQvJk0 pMNO3NzlIJeXJmnFJdncukcX+TBLX4mXnvPaU7lY1GmJkxpUiQknKwIJD9amhIRZz+KA ekrE+qKhXQeKgqc9l+0SLjFJg+zqoh+pQTFboLV7tOZ0KvfySCpkWCaF8bK1cLTssNHC CzWXrSxUxjDTcINSSzB9Bw9RKuxH5ftJCQ5eQAzjClWkSJS1zkq5uKGtyTFPQCribCf1 DmYuJIdtEM3xL/w0LuCa6FTD+CUew/r7DUa8t0FGOvzoxCKb7Rp6rVXrFKb/x1s0bcyV rG3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature; bh=99WBOf5UoAPsWbdwuj7ZlNsSBTYs3KFdTC1Z3Pp7lX8=; b=hgPgY0NmpNLETpIp3XVNANZ5kQDbRIlHLgPGWYPF2dzJLhcrCCqnxMZGMc0cuLvg+N UTOIg8uFpG4lSRrfeUtx6uSAlkvl2Tp33+lCCbVOncNQV9ErFKSk2Hvc049YMJaGmQbx F5ZopFRZI7lutb6VYT1IxZSXV9HAFmGpfRd7vUXMVKz1ik2ii3UVp4jSdDx3Kua1Q8rM xv7IUZW1fcfHyRj+qwdY1Nvxd2IxOLFBAukZtJGnUH0sLwJr82ow0Bb8va+mFpB6OAAy bZqJ4JVknTnRF8yuzn5kBe3gO7vorQ9uA0ot0RcyxRstKRZ9nGI4P3DoOSdCTHimSDjd uqGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d614fuCn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r129si7949141itb.37.2018.12.23.08.39.25; Sun, 23 Dec 2018 08:39:38 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=d614fuCn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbeLWG4N (ORCPT + 99 others); Sun, 23 Dec 2018 01:56:13 -0500 Received: from mail-vs1-f41.google.com ([209.85.217.41]:41549 "EHLO mail-vs1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726745AbeLWG4N (ORCPT ); Sun, 23 Dec 2018 01:56:13 -0500 Received: by mail-vs1-f41.google.com with SMTP id t17so5774316vsc.8; Sat, 22 Dec 2018 22:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=99WBOf5UoAPsWbdwuj7ZlNsSBTYs3KFdTC1Z3Pp7lX8=; b=d614fuCn1s/3Gd8sRoXWrelq8zDAF6F3Q8NAA5TZH25ttQH4cboZhtQCg+JFhQs3d7 68meu54C2YQxR9hxclBaBS52WBkd/nUn070DKaXkLCqao5gsZyLkoXRKdcECfkRmbqcf ur3T7WWNo0kQnSWucOf+o/OO3gzJC7Ens2FmervMYDXcB5oCmr4cailoCTz4CAxloIvU Zzk0LF9vTP7YMYNgndVvP43mOd4xLNXe4fDWkiGKleVEm+s3SvBvGZ1B6dBIUoE7eQxU iBC77xo5XavU7OiW3if9nw/5rAG9i6xpSnCdXjaUQtToQiHdc6iU7IFe1eGkR5EZ7rUr EmpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=99WBOf5UoAPsWbdwuj7ZlNsSBTYs3KFdTC1Z3Pp7lX8=; b=EUj0xMwE54Ev9zWVbVuEZtZd0AWzdJV7ryr5T02atljDwBQ1EHzMSYKo2CoJ84Juty eJW94asAyiIDr9sm6xE1ZVoIq/J//XOm7RDaKTf3c+VlZ85tGk7uJP/QFFF0WIsqpow8 UaeBFDYi2yVJwc+uYnxioJr0gevBQkRWrxJkAVdoYBQ32FOk2wF9Dc5kyldxeZCUDoFy qxVjdUKRmkVrcUVayc5cG1B3tV4Q3Rsjxpyl/60jd3bVuZh/myX+4GrobZ2H59CyEVUM sDW4OnWHt7a9MURM0bHn0EZ4kcL1gHc8PkY5YPzk++SqWStX3hxdEV9Zo2fRgfDUouwf oEOQ== X-Gm-Message-State: AA+aEWZXqKZSlbgo69NKlLT8WQQaAAJ1x8FWLL8ijwfFr5ylZuFSzCZW Fzi48dYxfRTsaVvX+/SE8Z6ZOAEHP0cSjA9ayFVRoTls X-Received: by 2002:a67:4e5d:: with SMTP id c90mr3654106vsb.72.1545548172143; Sat, 22 Dec 2018 22:56:12 -0800 (PST) MIME-Version: 1.0 From: Da Shi Cao Date: Sun, 23 Dec 2018 14:56:01 +0800 Message-ID: Subject: [BUG]Uncalibrated TSC is not accurate enough as a time keeper To: linux-kernel@vger.kernel.org, linux-x86_64@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpu_khz and tsc_khz are now read directly by the cpuid instruction, and they are deemed to be very accurate. But this is not the case in our situation. The OS time lags behind about 8 seconds per hour. The CPU information is as follows: processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 85 model name : Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz stepping : 4 microcode : 0x200004d cpu MHz : 2300.000 cache size : 25344 KB physical id : 0 siblings : 36 core id : 0 cpu cores : 18 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 22 It is this "cpuid level 22" that makes the kernel 4.14 to read both cpu_khz and tsc_khz directly by instruction "cpuid", and the TSC is thought to be very accurate, but in fact it is not. ------------ * TSC frequency determined by CPUID is a "hardware reported" * frequency and is the most accurate one so far we have. This * is considered a known frequency. +* +* The assumption may not be valid! +* */ - setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);