Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp589763imm; Wed, 20 Jun 2018 03:29:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL00qlOAbowmogD7mAHxYZbosFlDIJC7r87GvqZdDRsYrMF3zckYL3IGZJapGml63Nk2CEk X-Received: by 2002:a17:902:aa01:: with SMTP id be1-v6mr22980639plb.296.1529490561055; Wed, 20 Jun 2018 03:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529490561; cv=none; d=google.com; s=arc-20160816; b=l6YyMkG65o7TGt59YFz6NfVGzgHkko803Q4CwbhrACCGl199QyeaWaE16k7OWtJ5nj mCmZsPTJdlkTDvxVOUfSXWOfFx1gxYCnYZ7PUtfTjFpZet7t41z0U2zHdTazN3bHywYt TZpY9v5by6FlO2GsUZ0iivU0NUsenm7m4Biu7fRTOMnt68Xl8beKTdsdJBEfHGyVf1E+ d3ikZvvGJSe67jUtkEqQRLLpXRuN/E2GeYqZJOxIQrnZupluFv3Vx4w71+pSMXcINtO1 Fqx75YsrYdC+jdKaQ/JyR6k76zMvJxFXCcg7xXQwFTAYtMdqw1APBjap5kJmaben8q3i XA0g== 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=CTW6404QXSchzB0V3WULh+F2MvQHhFipBlB2O3ripas=; b=YlEiVtp2ADIRsrUgS4d37CFnltwyVfQbyxYKsG+6FMsVsQnlTaedXm5TMZa+ja903D 4C3b7UHM91WiwjnBf9iG0uhYlLEBdCjpJMie2poYFTZgTj0S5R8wvxuhTd4fbC8Ag9PF +8SDoY1EkCfTVZm9xK6pKBNcPwTQrFI9Qx5ZkfhrYe/fn/MXn1JbG5m6qYZA0f2FvGmf OZ6w1AMywadidODWsTTgMHouGn1Da1/Vqtfiq8wCA28Ej9MxrIlcMw4iRTzxDdTD4y4T AH2Ktugk4mrNllg2k5NF2cTPBs1noXg2QYKLX3/ztV/ffdBJItnXdAAYNIRFhedJObhn 2O9g== 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 v26-v6si1212360pge.323.2018.06.20.03.29.06; Wed, 20 Jun 2018 03:29:21 -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 S1753011AbeFTK1h (ORCPT + 99 others); Wed, 20 Jun 2018 06:27:37 -0400 Received: from mga06.intel.com ([134.134.136.31]:31036 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbeFTK1g (ORCPT ); Wed, 20 Jun 2018 06:27:36 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2018 03:27:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,246,1526367600"; d="scan'208";a="50809752" Received: from shbuild888.sh.intel.com (HELO localhost) ([10.239.146.239]) by orsmga008.jf.intel.com with ESMTP; 20 Jun 2018 03:27:33 -0700 Date: Wed, 20 Jun 2018 18:29:46 +0800 From: Feng Tang To: Thomas Gleixner Cc: Pavel Tatashin , 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, 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 v10 7/7] x86/tsc: use tsc early Message-ID: <20180620102946.jdvyvv7jvhhjvskv@shbuild888> References: <20180615174204.30581-1-pasha.tatashin@oracle.com> <20180615174204.30581-8-pasha.tatashin@oracle.com> <20180620101241.5vhmyvdjbenldp4r@shbuild888> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Wed, Jun 20, 2018 at 12:16:36PM +0200, Thomas Gleixner wrote: > On Wed, 20 Jun 2018, Feng Tang wrote: > > On Wed, Jun 20, 2018 at 01:52:10AM +0200, Thomas Gleixner wrote: > > > > > > static DEFINE_STATIC_KEY_FALSE(__use_tsc); > > > +static DEFINE_STATIC_KEY_TRUE(tsc_early_enabled); > > > > One potential problem may be the several static_keys used here, > > the "__use_tsc", the "__sched_clock_stable", it may not be used > > very early in boot phase. As the the static_branch_enable() will > > use pageing related code while the paging is not setup ready yet. > > I know how static keys work and thats the reason for having the extra > conditional. The key is disabled at a point where paging is available. Maybe I'm wrong, for printk timestamp, it uses the local_clock() thus sched_clock_cpu() sched_clock_stable check the static_key "__sched_clock_stable" which is defined FALSE, and need a static_branch_enable() to take effect Thanks, Feng > > > > /* > > > * Scheduler clock - returns current time in nanosec units. > > > */ > > > u64 native_sched_clock(void) > > > { > > > - if (static_branch_likely(&__use_tsc)) { > > > - u64 tsc_now = rdtsc(); > > > + if (static_branch_likely(&__use_tsc)) > > > + return cycles_2_ns(rdtsc()); > > > > > > - /* return the value in ns */ > > > - return cycles_2_ns(tsc_now); > > > + if (static_branch_unlikely(&tsc_early_enabled)) { > > > + if (tsc_early_sched_clock) > > > + return cycles_2_ns(rdtsc()); > > > } > > Thanks, > > tglx