Received: by 10.213.65.68 with SMTP id h4csp234617imn; Tue, 20 Mar 2018 02:02:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELsPGz+77vFtSet4vxv31kVvr7K4lbldRZahWsZiW/hLBxssT4FfTafr+Nrrl9dZ564skx8s X-Received: by 10.98.72.10 with SMTP id v10mr12974829pfa.148.1521536520528; Tue, 20 Mar 2018 02:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521536520; cv=none; d=google.com; s=arc-20160816; b=x13wCM418N0Dm/lXHHpbAqhaXXxzkqbzsTL2oA96AWnCxNzfJ/d1JCGpJnX7mFum9I GsTua3Ve9r0UnrBZ0HGpiWm8XRuJ8vpPpGhi/UXpmWOjYUy4p/kH131uaVZX0HwcnF05 6JKBBN4KjKdge2JMwaDlIdrnGzZ0v0e0TtQtTmtaQ+oVi/d1GAk5QZ3A+9QhxCdjt5Ic cv71al2oJFF8VDjSSaoW9ZJx2f+EgzSriYrOyllnsCLZNTG75BG1ycIGVn+PyZhEwDxp QdY8cRXrl9bjMjeCMgutmNQB3p5g7jz9U+2LNq8EBkHeVQSDmAFv+MeX4TEq1/9BMvxn RZgA== 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=fp8LC1cgRMNkRKeAoYx0Xx4sYuBc4lYZ/AI3k19XmT8=; b=mvMQy41xBhgsqNLty4LfLyd0MyRUDgrhu0cBCffWlLm+cpyoJwvfxsfiXdQ6IDi7kg ZoClUj7ZNXdEVHs8Tx579fwuTZ6OK2Uqf+EoFozwv8lo2YQuvTSB7/mm+uiz0WW1Vr0W qnR3F2BJA5FBcg9dXwt4F5hsxmNo/G4+jkRewBtegrPh+8rbnGRcg37Sb/NIXsojoeEZ VZ4Tocwe/BsNg3PZsldPm3UqGpJiP5hFTcVPnaYWqZL7R3SSMK17MA/4k2PTxLLvdMvj KSxJwsmV2zIj81/0i20MCy+wk2FZQ1HXmERFdryaWT1qFiogV6w2uijU6bsmmlIgD9j6 4a1g== 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 f15-v6si1194889plr.454.2018.03.20.02.01.43; Tue, 20 Mar 2018 02:02:00 -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 S1752341AbeCTI7K (ORCPT + 99 others); Tue, 20 Mar 2018 04:59:10 -0400 Received: from mga12.intel.com ([192.55.52.136]:7587 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751981AbeCTI7J (ORCPT ); Tue, 20 Mar 2018 04:59:09 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 01:59:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,334,1517904000"; d="scan'208";a="25456196" Received: from sofia.sh.intel.com (HELO sofia) ([10.239.147.120]) by fmsmga007.fm.intel.com with ESMTP; 20 Mar 2018 01:59:07 -0700 Date: Tue, 20 Mar 2018 16:58:35 +0800 From: "Liu, Changcheng" To: Peter Zijlstra Cc: tglx@linutronix.de, hpa@zytor.com, douly.fnst@cn.fujitsu.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/ioapic: don't use unstable TSC to detect timer IRQ Message-ID: <20180320085835.GA56497@sofia> References: <20180320084255.GA187704@sofia> <20180320084929.GP4043@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180320084929.GP4043@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09:49 Tue 20 Mar, Peter Zijlstra wrote: > On Tue, Mar 20, 2018 at 04:42:55PM +0800, Liu, Changcheng wrote: > > In rare case, the TSC is every unstable or can't sync with > > real time hardware clock. > > However did you manage that? Please provide _FAR_ more details. [Changcheng] TSC is simulated and HPET is hardware implemented. TSC can't sync with HPET. When running linux, the TSC grows too fast and HPET can't trigger periodic timer interrupt in time which is used to update jiffies. > > > diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h > > index cf5d53c..dcfc5b9 100644 > > --- a/arch/x86/include/asm/tsc.h > > +++ b/arch/x86/include/asm/tsc.h > > @@ -17,6 +17,7 @@ typedef unsigned long long cycles_t; > > > > extern unsigned int cpu_khz; > > extern unsigned int tsc_khz; > > +extern int tsc_unstable; > > > > extern void disable_TSC(void); > > > > diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c > > index 7c55387..0809ec6 100644 > > --- a/arch/x86/kernel/apic/io_apic.c > > +++ b/arch/x86/kernel/apic/io_apic.c > > @@ -1643,7 +1643,7 @@ static int __init timer_irq_works(void) > > local_save_flags(flags); > > local_irq_enable(); > > > > - if (boot_cpu_has(X86_FEATURE_TSC)) > > + if (boot_cpu_has(X86_FEATURE_TSC) && !tsc_unstable) > > delay_with_tsc(); > > else > > delay_without_tsc(); > > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > > index fb43027..27b1bae 100644 > > --- a/arch/x86/kernel/tsc.c > > +++ b/arch/x86/kernel/tsc.c > > @@ -36,7 +36,8 @@ EXPORT_SYMBOL(tsc_khz); > > /* > > * TSC can be unstable due to cpufreq or due to unsynced TSCs > > */ > > -static int __read_mostly tsc_unstable; > > +int __read_mostly tsc_unstable; > > +EXPORT_SYMBOL(tsc_unstable); > > > > /* native_sched_clock() is called before tsc_init(), so > > we must start with the TSC soft disabled to prevent > > No, absolutely not. Even when the TSC is normally deemed unstable, which > typically means it is not sync'ed between cores, it is still perfectly > suitable to be used for delay loops.