Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1604486imm; Wed, 20 Jun 2018 22:54:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKuBfakYOnmomEFCNPONc2zhn22ulBdTtJTbHepOnvJL6+anStUDSd5mUSKUUgp8wenY3Dz X-Received: by 2002:aa7:818b:: with SMTP id g11-v6mr25914974pfi.50.1529560476568; Wed, 20 Jun 2018 22:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529560476; cv=none; d=google.com; s=arc-20160816; b=Glq/XF6nDrvzy3ZrxD4M+sexIGFMDjJU21B9IvxpoehGM6M0pGsMPCy3Pue+jqwu1L xNgtGlz7H/rsEqO5V1XSfG8506tsdejAzcJzc3DjrYEASS8UmdbkQ9VUEhilGaQEOwEC mlpqOk4tK8KNVEfAz2wqBJ4+Sc0I2ls741/LcgVm+EMuGyzRoip7NpmsUqGUN1ZHRjsX LFvoHjA9c6hw8tnKu6Kq2SqDF/zIbCjmZuEe3fp5Gdu39iJR+8HayE45S08ti0n4hukY E1YjkG+pVCZtKq4ea8wu5gPywF645mak60QUe6U/djR75slPE57XiZOCgCzy2JFeft0r weGw== 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:arc-authentication-results; bh=Zn00SNNUprG04mmPIpquAIdFGrikj+xVdALVKOl/Vt4=; b=hI/aMJRSqbMd4fwRaM/0TiHuPiLlQ2ASUY7hMcV3bqg0IdV15Ocvg/zhM8E2i/1j2R jnYK5qhhRJLBI0Lu/crdrADqSw/tKrJrKAuN1O9XZtiHvY/zitF/BMZ3igtJOhifXgRO shjQvzfnOresdHlsepcRlJxk1nW7dKmFrwjRGAur7QTJ+bSXbZAsd+pKcc/PKyM78ioS AdH+zKtM9mYmnlnIZotqOKsmmgBayw4sWRGGPCIIkBJPezlm0KxhMXaS/guTLDFjQJUu gL1nyP7Tds0L56TV+qWId24PxJ0KXmExw2Av+92UibjfM7xLGkyZ/csQUI2O9CUfASRQ Tcpw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u127-v6si3309676pgc.482.2018.06.20.22.53.52; Wed, 20 Jun 2018 22:54:36 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932748AbeFUFti (ORCPT + 99 others); Thu, 21 Jun 2018 01:49:38 -0400 Received: from mga04.intel.com ([192.55.52.120]:54762 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932633AbeFUFth (ORCPT ); Thu, 21 Jun 2018 01:49:37 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2018 22:49:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,250,1526367600"; d="scan'208";a="68746093" Received: from shbuild888.sh.intel.com (HELO localhost) ([10.239.146.239]) by orsmga002.jf.intel.com with ESMTP; 20 Jun 2018 22:49:29 -0700 Date: Thu, 21 Jun 2018 13:51:44 +0800 From: Feng Tang To: Pavel Tatashin Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux@armlinux.org.uk, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, john.stultz@linaro.org, sboyd@codeaurora.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, douly.fnst@cn.fujitsu.com, peterz@infradead.org, prarit@redhat.com, pmladek@suse.com, gnomes@lxorguk.ukuu.org.uk Subject: Re: [PATCH v11 6/6] x86/tsc: use tsc early Message-ID: <20180621055144.i65hhyqe5dofop33@shbuild888> References: <20180620212700.29178-1-pasha.tatashin@oracle.com> <20180620212700.29178-7-pasha.tatashin@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180620212700.29178-7-pasha.tatashin@oracle.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavel, On Wed, Jun 20, 2018 at 05:27:00PM -0400, Pavel Tatashin wrote: > We want to get timestamps and high resultion clock available to us as early > as possible in boot. But, native_sched_clock() outputs time based either on > tsc after tsc_init() is called later in boot, or using jiffies when clock > interrupts are enabled, which is also happens later in boot. > > On the other hand, we know tsc frequency from as early as when > tsc_early_delay_calibrate() is called. So, we use the early tsc calibration > to output timestamps early. Later in boot when tsc_init() is called we > calibrate tsc again using more precise methods, and start using that. > > Since sched_clock() is in a hot path, we want to make sure that no > regressions are introduced to this function after machine is booted, this > is why we are using static branch that is enabled by default, but is > disabled once we have initialized a permanent clock source. > > Signed-off-by: Pavel Tatashin > --- > arch/x86/kernel/tsc.c | 64 ++++++++++++++++++++++++++++++------------- > 1 file changed, 45 insertions(+), 19 deletions(-) > > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > index 654a01cc0358..1dd69612c69c 100644 > --- a/arch/x86/kernel/tsc.c > +++ b/arch/x86/kernel/tsc.c > @@ -39,6 +39,9 @@ EXPORT_SYMBOL(tsc_khz); > static int __read_mostly tsc_unstable; > > static DEFINE_STATIC_KEY_FALSE(__use_tsc); > +static DEFINE_STATIC_KEY_TRUE(tsc_early_enabled); Do we still need add a static_key? after Peter worked out the patch to enable ealy jump_label_init? Thanks, Feng