All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/tsc: split X86_FEATURE_TSC_RELIABLE into two
@ 2016-11-01 17:14 Bin Gao
  2016-11-01 17:14 ` [PATCH 1/2] x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag Bin Gao
  2016-11-01 17:14 ` [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs Bin Gao
  0 siblings, 2 replies; 10+ messages in thread
From: Bin Gao @ 2016-11-01 17:14 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H Peter Anvin, x86
  Cc: Peter Zijlstra, linux-kernel, Bin Gao

This patch series split X86_FEATURE_TSC_RELIABLE into two separate
flags: X86_FEATURE_TSC_RELIABLE and X86_FEATURE_TSC_KNOWN_FREQ.
This change allows us to redefine TSC features at fine granularity.
This is driven by certain Intel processors/SoCs with frequency-known
TSC so the whole calibration stuff should be skipped.

Bin Gao (2):
  x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag
  x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs

 arch/x86/include/asm/cpufeatures.h  |  1 +
 arch/x86/kernel/tsc.c               | 15 ++++++++++++---
 arch/x86/kernel/tsc_msr.c           |  4 ++++
 arch/x86/platform/intel-mid/mfld.c  |  5 +++--
 arch/x86/platform/intel-mid/mrfld.c |  4 ++--
 5 files changed, 22 insertions(+), 7 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag
  2016-11-01 17:14 [PATCH 0/2] x86/tsc: split X86_FEATURE_TSC_RELIABLE into two Bin Gao
@ 2016-11-01 17:14 ` Bin Gao
  2016-11-09 21:09   ` Thomas Gleixner
  2016-11-01 17:14 ` [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs Bin Gao
  1 sibling, 1 reply; 10+ messages in thread
From: Bin Gao @ 2016-11-01 17:14 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H Peter Anvin, x86
  Cc: Peter Zijlstra, linux-kernel, Bin Gao

The X86_FEATURE_TSC_RELIABLE flag in Linux kernel implies both reliable
(at runtime) and trustable (at calibration). But reliable running and
trustable calibration are logically irrelevant. Per Thomas Gleixner's
suggestion we would like to split this flag into two separate flags:
X86_FEATURE_TSC_RELIABLE - running reliably
X86_FEATURE_TSC_KNOWN_FREQ - frequency is known (no calibration required)
These two flags allow Linux kernel to act differently based on
processor/SoC's capability, i.e. no watchdog on TSC if TSC is reliable,
and no calibration if TSC frequency is known.

Current Linux kernel already gurantees calibration is skipped for
processors that can report TSC frequency by CPUID or MSR. However, the
delayed calibration is still not skipped for these CPUID/MSR capable
processors. The new flag X86_FEATURE_TSC_KNOWN_FREQ added by this patch
will gurantee the delayed calibration is skipped.

Signed-off-by: Bin Gao <bin.gao@intel.com>
---
 arch/x86/include/asm/cpufeatures.h | 1 +
 arch/x86/kernel/tsc.c              | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index a396292..7f6a5f8 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -106,6 +106,7 @@
 #define X86_FEATURE_APERFMPERF	( 3*32+28) /* APERFMPERF */
 #define X86_FEATURE_EAGER_FPU	( 3*32+29) /* "eagerfpu" Non lazy FPU restore */
 #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */
+#define X86_FEATURE_TSC_KNOWN_FREQ ( 3*32+31) /* TSC has known frequency */
 
 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
 #define X86_FEATURE_XMM3	( 4*32+ 0) /* "pni" SSE-3 */
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 46b2f41..b4c82f8 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1283,10 +1283,10 @@ static int __init init_tsc_clocksource(void)
 		clocksource_tsc.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP;
 
 	/*
-	 * Trust the results of the earlier calibration on systems
-	 * exporting a reliable TSC.
+	 * When TSC frequency is known (generally got by MSR or CPUID), we skip
+	 * the refined calibration and directly register it as a clocksource.
 	 */
-	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) {
+	if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {
 		clocksource_register_khz(&clocksource_tsc, tsc_khz);
 		return 0;
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs
  2016-11-01 17:14 [PATCH 0/2] x86/tsc: split X86_FEATURE_TSC_RELIABLE into two Bin Gao
  2016-11-01 17:14 ` [PATCH 1/2] x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag Bin Gao
@ 2016-11-01 17:14 ` Bin Gao
  2016-11-09 21:25   ` Thomas Gleixner
  1 sibling, 1 reply; 10+ messages in thread
From: Bin Gao @ 2016-11-01 17:14 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H Peter Anvin, x86
  Cc: Peter Zijlstra, linux-kernel, Bin Gao

With X86_FEATURE_TSC_RELIABLE is split into X86_FEATURE_TSC_KNOWN_FREQ
and X86_FEATURE_TSC_KNOWN_FREQ, some platforms with reliable and
frequency-known TSC have to be marked with these new flags. These platforms
are Intel processors/SoCs supporting getting TSC frequency by MSR or CPUID.

Signed-off-by: Bin Gao <bin.gao@intel.com>
---
 arch/x86/kernel/tsc.c               | 9 +++++++++
 arch/x86/kernel/tsc_msr.c           | 4 ++++
 arch/x86/platform/intel-mid/mfld.c  | 5 +++--
 arch/x86/platform/intel-mid/mrfld.c | 4 ++--
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index b4c82f8..4197768 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -702,6 +702,15 @@ unsigned long native_calibrate_tsc(void)
 		}
 	}
 
+	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
+
+	/*
+	 * For Atom SoCs TSC is the only reliable clocksource.
+	 * Mark TSC reliable so no watchdog on it.
+	 */
+	if (boot_cpu_data.x86_model == INTEL_FAM6_ATOM_GOLDMONT)
+		setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
+
 	return crystal_khz * ebx_numerator / eax_denominator;
 }
 
diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
index 0fe720d..d6aa75a 100644
--- a/arch/x86/kernel/tsc_msr.c
+++ b/arch/x86/kernel/tsc_msr.c
@@ -100,5 +100,9 @@ unsigned long cpu_khz_from_msr(void)
 #ifdef CONFIG_X86_LOCAL_APIC
 	lapic_timer_frequency = (freq * 1000) / HZ;
 #endif
+
+	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
+	setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
+
 	return res;
 }
diff --git a/arch/x86/platform/intel-mid/mfld.c b/arch/x86/platform/intel-mid/mfld.c
index 1eb47b6..3fa41b4 100644
--- a/arch/x86/platform/intel-mid/mfld.c
+++ b/arch/x86/platform/intel-mid/mfld.c
@@ -49,8 +49,9 @@ static unsigned long __init mfld_calibrate_tsc(void)
 	fast_calibrate = ratio * fsb;
 	pr_debug("read penwell tsc %lu khz\n", fast_calibrate);
 	lapic_timer_frequency = fsb * 1000 / HZ;
-	/* mark tsc clocksource as reliable */
-	set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
+
+	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
+	setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
 
 	return fast_calibrate;
 }
diff --git a/arch/x86/platform/intel-mid/mrfld.c b/arch/x86/platform/intel-mid/mrfld.c
index 59253db..9477b7e 100644
--- a/arch/x86/platform/intel-mid/mrfld.c
+++ b/arch/x86/platform/intel-mid/mrfld.c
@@ -78,8 +78,8 @@ static unsigned long __init tangier_calibrate_tsc(void)
 	pr_debug("Setting lapic_timer_frequency = %d\n",
 			lapic_timer_frequency);
 
-	/* mark tsc clocksource as reliable */
-	set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
+	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
+	setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
 
 	return fast_calibrate;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag
  2016-11-01 17:14 ` [PATCH 1/2] x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag Bin Gao
@ 2016-11-09 21:09   ` Thomas Gleixner
       [not found]     ` <4460FA1017EA3844B646E90DA4E984057E2ECB7C@ORSMSX112.amr.corp.intel.com>
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2016-11-09 21:09 UTC (permalink / raw)
  To: Bin Gao; +Cc: Ingo Molnar, H Peter Anvin, x86, Peter Zijlstra, linux-kernel

On Tue, 1 Nov 2016, Bin Gao wrote:

> The X86_FEATURE_TSC_RELIABLE flag in Linux kernel implies both reliable
> (at runtime) and trustable (at calibration). But reliable running and
> trustable calibration are logically irrelevant. Per Thomas Gleixner's
> suggestion we would like to split this flag into two separate flags:
> X86_FEATURE_TSC_RELIABLE - running reliably
> X86_FEATURE_TSC_KNOWN_FREQ - frequency is known (no calibration required)
> These two flags allow Linux kernel to act differently based on
> processor/SoC's capability, i.e. no watchdog on TSC if TSC is reliable,
> and no calibration if TSC frequency is known.
> 
> Current Linux kernel already gurantees calibration is skipped for
> processors that can report TSC frequency by CPUID or MSR. However, the
> delayed calibration is still not skipped for these CPUID/MSR capable
> processors. The new flag X86_FEATURE_TSC_KNOWN_FREQ added by this patch
> will gurantee the delayed calibration is skipped.
> 
> Signed-off-by: Bin Gao <bin.gao@intel.com>
> ---
>  arch/x86/include/asm/cpufeatures.h | 1 +
>  arch/x86/kernel/tsc.c              | 6 +++---
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> index a396292..7f6a5f8 100644
> --- a/arch/x86/include/asm/cpufeatures.h
> +++ b/arch/x86/include/asm/cpufeatures.h
> @@ -106,6 +106,7 @@
>  #define X86_FEATURE_APERFMPERF	( 3*32+28) /* APERFMPERF */
>  #define X86_FEATURE_EAGER_FPU	( 3*32+29) /* "eagerfpu" Non lazy FPU restore */
>  #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */
> +#define X86_FEATURE_TSC_KNOWN_FREQ ( 3*32+31) /* TSC has known frequency */
>  
>  /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
>  #define X86_FEATURE_XMM3	( 4*32+ 0) /* "pni" SSE-3 */
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 46b2f41..b4c82f8 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -1283,10 +1283,10 @@ static int __init init_tsc_clocksource(void)
>  		clocksource_tsc.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP;
>  
>  	/*
> -	 * Trust the results of the earlier calibration on systems
> -	 * exporting a reliable TSC.
> +	 * When TSC frequency is known (generally got by MSR or CPUID), we skip
> +	 * the refined calibration and directly register it as a clocksource.
>  	 */
> -	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) {
> +	if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {

This causes a regression, because with only this patch applied the
architectures which use the reliable flag for this today are not longer
taking this path.

The proper thing to do here is to make this:

	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE) ||
	    boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {

and remove the RELIABLE flag ckeck after the existing users are converted.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs
  2016-11-01 17:14 ` [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs Bin Gao
@ 2016-11-09 21:25   ` Thomas Gleixner
       [not found]     ` <4460FA1017EA3844B646E90DA4E984057E2ECB85@ORSMSX112.amr.corp.intel.com>
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2016-11-09 21:25 UTC (permalink / raw)
  To: Bin Gao; +Cc: Ingo Molnar, H Peter Anvin, x86, Peter Zijlstra, linux-kernel

On Tue, 1 Nov 2016, Bin Gao wrote:
> @@ -702,6 +702,15 @@ unsigned long native_calibrate_tsc(void)
>  		}
>  	}
>  
> +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);

I can understand the one below, but this one changes existing behaviour w/o
explaining why this is correct and desired. If at all then this wants to be
a seperate patch and not just mingled in your goldmont update.

> +	/*
> +	 * For Atom SoCs TSC is the only reliable clocksource.
> +	 * Mark TSC reliable so no watchdog on it.
> +	 */
> +	if (boot_cpu_data.x86_model == INTEL_FAM6_ATOM_GOLDMONT)
> +		setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
> +
>  	return crystal_khz * ebx_numerator / eax_denominator;
>  }
>  
> diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
> index 0fe720d..d6aa75a 100644
> --- a/arch/x86/kernel/tsc_msr.c
> +++ b/arch/x86/kernel/tsc_msr.c
> @@ -100,5 +100,9 @@ unsigned long cpu_khz_from_msr(void)
>  #ifdef CONFIG_X86_LOCAL_APIC
>  	lapic_timer_frequency = (freq * 1000) / HZ;
>  #endif
> +
> +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> +	setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);

Why is this automatically reliable and of known frequency?

This evades the long term TSC calibration and also disables the watchdog,
which might break stuff left and right.

Please makes these changes one by one and explain why they are correct on
their own, preferrably with some substantial backfrom from the hw folks.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH 1/2] x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag
       [not found]     ` <4460FA1017EA3844B646E90DA4E984057E2ECB7C@ORSMSX112.amr.corp.intel.com>
@ 2016-11-10 22:51       ` Bin Gao
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Gao @ 2016-11-10 22:51 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H Peter Anvin, x86@kernel.org Peter Zijlstra,
	linux-kernel, Bin Gao

> > --- a/arch/x86/kernel/tsc.c
> > +++ b/arch/x86/kernel/tsc.c
> > @@ -1283,10 +1283,10 @@ static int __init init_tsc_clocksource(void)
> >  		clocksource_tsc.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP;
> >  
> >  	/*
> > -	 * Trust the results of the earlier calibration on systems
> > -	 * exporting a reliable TSC.
> > +	 * When TSC frequency is known (generally got by MSR or CPUID), we skip
> > +	 * the refined calibration and directly register it as a clocksource.
> >  	 */
> > -	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) {
> > +	if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {
> 
> This causes a regression, because with only this patch applied the architectures which use the reliable flag for this today are not longer taking this path.
> 
> The proper thing to do here is to make this:
> 
> 	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE) ||
> 	    boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {
> 
> and remove the RELIABLE flag ckeck after the existing users are converted.

I Will fix this in next revision.
 
> Thanks,
> 
> 	tglx
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs
       [not found]     ` <4460FA1017EA3844B646E90DA4E984057E2ECB85@ORSMSX112.amr.corp.intel.com>
@ 2016-11-10 23:20       ` Bin Gao
  2016-11-10 23:26         ` Thomas Gleixner
  0 siblings, 1 reply; 10+ messages in thread
From: Bin Gao @ 2016-11-10 23:20 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H Peter Anvin, x86, Peter Zijlstra, linux-kernel, Bin Gao

> > @@ -702,6 +702,15 @@ unsigned long native_calibrate_tsc(void)
> >  		}
> >  	}
> >  
> > +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> 
> I can understand the one below, but this one changes existing behaviour w/o explaining why this is correct and desired. If at all then this wants to be a seperate patch and not just mingled in your goldmont update.

native_calibrate_tsc() implements determining TSC frequency via CPUID.
The purpose to add X86_FEATURE_TSC_KNOWN_FREQ flag is exactly for this case:
TSC frequency determined via CPUID or MSR are always correct and the whole
calibration should be skipped.

I will create a seperate patch for this to ensure it's not confusing with
the MSR related change below.

> 
> > +	/*
> > +	 * For Atom SoCs TSC is the only reliable clocksource.
> > +	 * Mark TSC reliable so no watchdog on it.
> > +	 */
> > +	if (boot_cpu_data.x86_model == INTEL_FAM6_ATOM_GOLDMONT)
> > +		setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
> > +
> >  	return crystal_khz * ebx_numerator / eax_denominator;  }
> >  
> > diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c 
> > index 0fe720d..d6aa75a 100644
> > --- a/arch/x86/kernel/tsc_msr.c
> > +++ b/arch/x86/kernel/tsc_msr.c
> > @@ -100,5 +100,9 @@ unsigned long cpu_khz_from_msr(void)  #ifdef 
> > CONFIG_X86_LOCAL_APIC
> >  	lapic_timer_frequency = (freq * 1000) / HZ;  #endif
> > +
> > +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> > +	setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
> 
> Why is this automatically reliable and of known frequency?

As I said above, TSC frequency determined by CPUID or MSR is always considered
"known" because it is reported by HW.
Regarding the reliable, unfortunately however, there is no a HW way to report
it. We were told by silicon design team it's "reliable".

> 
> This evades the long term TSC calibration and also disables the watchdog, which might break stuff left and right.
> 
> Please makes these changes one by one and explain why they are correct on their own, preferrably with some substantial backfrom from the hw folks.

Yes we confirmed with HW folks. TSC count is guaranteed to monotonically
increase at the fixed frequency even during S3/S0i3 state on these platforms.
This change will be seperate from CPUID related change in next revision.

> 
> Thanks,
> 
> 	tglx
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs
  2016-11-10 23:20       ` Bin Gao
@ 2016-11-10 23:26         ` Thomas Gleixner
  2016-11-11  0:06           ` Bin Gao
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2016-11-10 23:26 UTC (permalink / raw)
  To: Bin Gao
  Cc: Ingo Molnar, H Peter Anvin, x86, Peter Zijlstra, linux-kernel, Bin Gao

On Thu, 10 Nov 2016, Bin Gao wrote:
> > > @@ -702,6 +702,15 @@ unsigned long native_calibrate_tsc(void)
> > >  		}
> > >  	}
> > >  
> > > +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> > 
> > I can understand the one below, but this one changes existing behaviour w/o explaining why this is correct and desired. If at all then this wants to be a seperate patch and not just mingled in your goldmont update.
> 
> native_calibrate_tsc() implements determining TSC frequency via CPUID.
> The purpose to add X86_FEATURE_TSC_KNOWN_FREQ flag is exactly for this case:
> TSC frequency determined via CPUID or MSR are always correct and the whole
> calibration should be skipped.

Did you actually verify that this is correct and does not introduce NTP
issues compared to the long term calibration on such platforms?

We've been burnt before and myself and others wasted enough time already
debugging that crap.

> I will create a seperate patch for this to ensure it's not confusing with
> the MSR related change below.

Yes please.
 
> > > @@ -100,5 +100,9 @@ unsigned long cpu_khz_from_msr(void)  #ifdef 
> > > CONFIG_X86_LOCAL_APIC
> > >  	lapic_timer_frequency = (freq * 1000) / HZ;  #endif
> > > +
> > > +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> > > +	setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
> > 
> > Why is this automatically reliable and of known frequency?
> 

> As I said above, TSC frequency determined by CPUID or MSR is always considered
> "known" because it is reported by HW.
> Regarding the reliable, unfortunately however, there is no a HW way to report
> it. We were told by silicon design team it's "reliable".

Please add a comment which explains this in great length.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs
  2016-11-11  0:06           ` Bin Gao
@ 2016-11-11  0:01             ` Thomas Gleixner
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Gleixner @ 2016-11-11  0:01 UTC (permalink / raw)
  To: Bin Gao
  Cc: Ingo Molnar, H Peter Anvin, x86, Peter Zijlstra, linux-kernel, Bin Gao

On Thu, 10 Nov 2016, Bin Gao wrote:

> On Fri, Nov 11, 2016 at 12:26:40AM +0100, Thomas Gleixner wrote:
> > On Thu, 10 Nov 2016, Bin Gao wrote:
> > > > > @@ -702,6 +702,15 @@ unsigned long native_calibrate_tsc(void)
> > > > >  		}
> > > > >  	}
> > > > >  
> > > > > +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> > > > 
> > > > I can understand the one below, but this one changes existing behaviour w/o explaining why this is correct and desired. If at all then this wants to be a seperate patch and not just mingled in your goldmont update.
> > > 
> > > native_calibrate_tsc() implements determining TSC frequency via CPUID.
> > > The purpose to add X86_FEATURE_TSC_KNOWN_FREQ flag is exactly for this case:
> > > TSC frequency determined via CPUID or MSR are always correct and the whole
> > > calibration should be skipped.
> > 
> > Did you actually verify that this is correct and does not introduce NTP
> > issues compared to the long term calibration on such platforms?
> > 
> > We've been burnt before and myself and others wasted enough time already
> > debugging that crap.
> 
> Yes, we had a 24 hours test before on one of the CPUID capable platforms.
> With PIT calibrated frequency, we got more than 3 seconds drift whereas
> with CPUID determined frequency we only got less than 0.5 second drift.

So all that want's to be mentioned in the changelog when you add this flag
to that CPUID code path.
 
> Another fact is that on MSR capable platforms, PIT/HPET is generally not
> available so calibration won't work at all.

I know and still it want's to be documented. If you had done that in the
first place I would not ask those questions at all.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs
  2016-11-10 23:26         ` Thomas Gleixner
@ 2016-11-11  0:06           ` Bin Gao
  2016-11-11  0:01             ` Thomas Gleixner
  0 siblings, 1 reply; 10+ messages in thread
From: Bin Gao @ 2016-11-11  0:06 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H Peter Anvin, x86, Peter Zijlstra, linux-kernel, Bin Gao

On Fri, Nov 11, 2016 at 12:26:40AM +0100, Thomas Gleixner wrote:
> On Thu, 10 Nov 2016, Bin Gao wrote:
> > > > @@ -702,6 +702,15 @@ unsigned long native_calibrate_tsc(void)
> > > >  		}
> > > >  	}
> > > >  
> > > > +	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> > > 
> > > I can understand the one below, but this one changes existing behaviour w/o explaining why this is correct and desired. If at all then this wants to be a seperate patch and not just mingled in your goldmont update.
> > 
> > native_calibrate_tsc() implements determining TSC frequency via CPUID.
> > The purpose to add X86_FEATURE_TSC_KNOWN_FREQ flag is exactly for this case:
> > TSC frequency determined via CPUID or MSR are always correct and the whole
> > calibration should be skipped.
> 
> Did you actually verify that this is correct and does not introduce NTP
> issues compared to the long term calibration on such platforms?
> 
> We've been burnt before and myself and others wasted enough time already
> debugging that crap.

Yes, we had a 24 hours test before on one of the CPUID capable platforms.
With PIT calibrated frequency, we got more than 3 seconds drift whereas
with CPUID determined frequency we only got less than 0.5 second drift.

Another fact is that on MSR capable platforms, PIT/HPET is generally not
available so calibration won't work at all.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-11-11  0:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-01 17:14 [PATCH 0/2] x86/tsc: split X86_FEATURE_TSC_RELIABLE into two Bin Gao
2016-11-01 17:14 ` [PATCH 1/2] x86/tsc: add X86_FEATURE_TSC_KNOWN_FREQ flag Bin Gao
2016-11-09 21:09   ` Thomas Gleixner
     [not found]     ` <4460FA1017EA3844B646E90DA4E984057E2ECB7C@ORSMSX112.amr.corp.intel.com>
2016-11-10 22:51       ` Bin Gao
2016-11-01 17:14 ` [PATCH 2/2] x86: use KNOWN_FREQ and RELIABLE TSC flags on certain processors/SoCs Bin Gao
2016-11-09 21:25   ` Thomas Gleixner
     [not found]     ` <4460FA1017EA3844B646E90DA4E984057E2ECB85@ORSMSX112.amr.corp.intel.com>
2016-11-10 23:20       ` Bin Gao
2016-11-10 23:26         ` Thomas Gleixner
2016-11-11  0:06           ` Bin Gao
2016-11-11  0:01             ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.