Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1599488 > unrolled thread

x86/tsc: Fix ART for TSC_KNOWN_FREQ

Started byPeter Zijlstra <peterz@infradead.org>
First post2017-03-13 16:00 +0100
Last post2017-03-13 21:20 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  x86/tsc: Fix ART for TSC_KNOWN_FREQ Peter Zijlstra <peterz@infradead.org> - 2017-03-13 16:00 +0100
    [tip:x86/urgent] x86/tsc: Fix ART for TSC_KNOWN_FREQ tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2017-03-13 20:00 +0100
    Re: x86/tsc: Fix ART for TSC_KNOWN_FREQ Thomas Gleixner <tglx@linutronix.de> - 2017-03-13 20:10 +0100
      Re: x86/tsc: Fix ART for TSC_KNOWN_FREQ Peter Zijlstra <peterz@infradead.org> - 2017-03-13 21:20 +0100

#1599488 — x86/tsc: Fix ART for TSC_KNOWN_FREQ

FromPeter Zijlstra <peterz@infradead.org>
Date2017-03-13 16:00 +0100
Subjectx86/tsc: Fix ART for TSC_KNOWN_FREQ
Message-ID<tkzC2-1Yl-13@gated-at.bofh.it>
Subhransu reported that convert_art_to_tsc() isn't working for him.

It turns out that because of commit:

  57779dc2b3b7 ("x86, tsc: Skip refined tsc calibration on systems with reliable TSC")

Systems with TSC_KNOWN_FREQ (due to having CPUID.15h) will not run the
refined calibration thing, and then forget to set the ART clocksource
relation.

We cannot set the ART relation prior to running the refined calibration;
therefore duplicate the lines.

XXX: should we clear this in mark_tsc_unstable() ?

Reported-by: "Prusty, Subhransu S" <subhransu.s.prusty@intel.com>
Cc: kevin.b.stanton@intel.com
Cc: Alok N Kataria <akataria@vmware.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Christopher Hall <christopher.s.hall@intel.com>
Fixes: 57779dc2b3b7 ("x86, tsc: Skip refined tsc calibration on systems with reliable TSC")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/kernel/tsc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 4f7a9833d8e5..c73a7f9e881a 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1333,6 +1333,8 @@ static int __init init_tsc_clocksource(void)
 	 * the refined calibration and directly register it as a clocksource.
 	 */
 	if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {
+		if (boot_cpu_has(X86_FEATURE_ART))
+			art_related_clocksource = &clocksource_tsc;
 		clocksource_register_khz(&clocksource_tsc, tsc_khz);
 		return 0;
 	}

[toc] | [next] | [standalone]


#1599690 — [tip:x86/urgent] x86/tsc: Fix ART for TSC_KNOWN_FREQ

Fromtip-bot for Peter Zijlstra <tipbot@zytor.com>
Date2017-03-13 20:00 +0100
Subject[tip:x86/urgent] x86/tsc: Fix ART for TSC_KNOWN_FREQ
Message-ID<tkDmh-4GD-3@gated-at.bofh.it>
In reply to#1599488
Commit-ID:  44fee88cea43d3c2cac962e0439cb10a3cabff6d
Gitweb:     http://git.kernel.org/tip/44fee88cea43d3c2cac962e0439cb10a3cabff6d
Author:     Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 13 Mar 2017 15:57:12 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 13 Mar 2017 19:50:23 +0100

x86/tsc: Fix ART for TSC_KNOWN_FREQ

Subhransu reported that convert_art_to_tsc() isn't working for him.

The ART to TSC relation is only set up for systems which use the refined
TSC calibration. Systems with known TSC frequency (available via CPUID 15)
are not using the refined calibration and therefor the ART to TSC relation
is never established.

Add the setup to the known frequency init path which skips ART
calibration. The init code needs to be duplicated as for systems which use
refined calibration the ART setup must be delayed until calibration has
been done.

The problem has been there since the ART support was introdduced, but only
detected now because Subhransu tested the first time on hardware which has
TSC frequency enumerated via CPUID 15.

Note for stable: The conditional has changed from TSC_RELIABLE to
     	 	 TSC_KNOWN_FREQUENCY.

[ tglx: Rewrote changelog and identified the proper 'Fixes' commit ]

Fixes: f9677e0f8308 ("x86/tsc: Always Running Timer (ART) correlated clocksource")
Reported-by: "Prusty, Subhransu S" <subhransu.s.prusty@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Cc: christopher.s.hall@intel.com
Cc: kevin.b.stanton@intel.com
Cc: john.stultz@linaro.org
Cc: akataria@vmware.com
Link: http://lkml.kernel.org/r/20170313145712.GI3312@twins.programming.kicks-ass.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/tsc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 4f7a983..c73a7f9 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1333,6 +1333,8 @@ static int __init init_tsc_clocksource(void)
 	 * the refined calibration and directly register it as a clocksource.
 	 */
 	if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {
+		if (boot_cpu_has(X86_FEATURE_ART))
+			art_related_clocksource = &clocksource_tsc;
 		clocksource_register_khz(&clocksource_tsc, tsc_khz);
 		return 0;
 	}

[toc] | [prev] | [next] | [standalone]


#1599697

FromThomas Gleixner <tglx@linutronix.de>
Date2017-03-13 20:10 +0100
Message-ID<tkDvX-501-7@gated-at.bofh.it>
In reply to#1599488
On Mon, 13 Mar 2017, Peter Zijlstra wrote:

> 
> Subhransu reported that convert_art_to_tsc() isn't working for him.
> 
> It turns out that because of commit:
> 
>   57779dc2b3b7 ("x86, tsc: Skip refined tsc calibration on systems with reliable TSC")

That's the wrong culprit. The problem was introduced with the ART support
patches. I fixed the changelog up.

> Systems with TSC_KNOWN_FREQ (due to having CPUID.15h) will not run the
> refined calibration thing, and then forget to set the ART clocksource
> relation.
> 
> We cannot set the ART relation prior to running the refined calibration;
> therefore duplicate the lines.
> 
> XXX: should we clear this in mark_tsc_unstable() ?
 
It's already handled. get_device_system_timestamp() which convert ART to
clock monotonic checks whether the timekeeper clocksource is the same as
the correlated ART clocksource, i.e. TSC. So when timekeeping switches away
from TSC get_device_system_timestamp() returns -ENODEV.

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1599777

FromPeter Zijlstra <peterz@infradead.org>
Date2017-03-13 21:20 +0100
Message-ID<tkEBH-5Mm-5@gated-at.bofh.it>
In reply to#1599697
On Mon, Mar 13, 2017 at 08:04:14PM +0100, Thomas Gleixner wrote:
> On Mon, 13 Mar 2017, Peter Zijlstra wrote:
> 
> > 
> > Subhransu reported that convert_art_to_tsc() isn't working for him.
> > 
> > It turns out that because of commit:
> > 
> >   57779dc2b3b7 ("x86, tsc: Skip refined tsc calibration on systems with reliable TSC")
> 
> That's the wrong culprit. The problem was introduced with the ART support
> patches. I fixed the changelog up.

Right; thanks for untangling that history.

> > Systems with TSC_KNOWN_FREQ (due to having CPUID.15h) will not run the
> > refined calibration thing, and then forget to set the ART clocksource
> > relation.
> > 
> > We cannot set the ART relation prior to running the refined calibration;
> > therefore duplicate the lines.
> > 
> > XXX: should we clear this in mark_tsc_unstable() ?
>  
> It's already handled. get_device_system_timestamp() which convert ART to
> clock monotonic checks whether the timekeeper clocksource is the same as
> the correlated ART clocksource, i.e. TSC. So when timekeeping switches away
> from TSC get_device_system_timestamp() returns -ENODEV.

Ah right. Couldn't find that in a hurry.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web