Skip to contentSkip to conversation

Calling check_system_tsc_reliable() before unsynchronized_tsc()

PATCH RESEND In review Zhenzhong Duan 3 participants 4 messages Jun 21, 2017 – Jun 23, 2017 x86

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Calling check_system_tsc_reliable() before unsynchronized_tsc()

unsynchronized_tsc() checks value of tsc_clocksource_reliable which is set by check_system_tsc_reliable(). It's better to move check_system_tsc_reliable() at front.

Though X86_FEATURE_CONSTANT_TSC is usually set for TSC reliable system, just in case.

---
 arch/x86/kernel/tsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/tsc.c +2 -2
index 714dfba..a316bdd 100644
@@ -1412,11 +1412,11 @@ void __init tsc_init(void)
 
 	use_tsc_delay();
 
+	check_system_tsc_reliable();
+
 	if (unsynchronized_tsc())
 		mark_tsc_unstable("TSCs unsynchronized");
 
-	check_system_tsc_reliable();
-
 	detect_art();
 }
 
Signature · 1 line
1.7.3
#1 lore raw

Zhenzhong,

On Wed, 21 Jun 2017, Zhenzhong Duan wrote:

So the patch format is now correct, but the subject line is missing a proper subsystem prefix. Please use 'git log 'path/to/patched/file' next time to see what the usually used prefix for a file is.

In this case it's: x86/tsc

Also please do not use [PATCH RESEND] when your patch is different from the version you sent before. Please use [PATCH v2] instead.

Quoted 3 lines

unsynchronized_tsc() checks value of tsc_clocksource_reliable which is set by check_system_tsc_reliable(). It's better to move check_system_tsc_reliable() at front.

Please make your statements affirmative. 'It's better' is a weak expression.

Quoted 2 lines

Though X86_FEATURE_CONSTANT_TSC is usually set for TSC reliable system, just in case.

So what you wanted to say here is:

tsc_clocksource_reliable is initialized in check_system_tsc_reliable(), but it is checked in unsynchronized_tsc() which is called before the initialization.

In practice that's not an issue because systems which mark the TSC reliable have X86_FEATURE_CONSTANT_TSC set as well, which is evaluated in unsynchronized_tsc() before tsc_clocksource_reliable.

Reorder the calls so initialization happens before usage.

All this information is also documented in Documentation/process/.

No need to resend. I'll fix it up for you this time.

Thanks,

tglx

#2 lore raw
Quoted 4 lines · Thomas Gleixner

Zhenzhong,

On Wed, 21 Jun 2017, Zhenzhong Duan wrote:

Quoted 8 lines

So the patch format is now correct, but the subject line is missing a proper subsystem prefix. Please use 'git log 'path/to/patched/file' next time to see what the usually used prefix for a file is.

In this case it's: x86/tsc

Also please do not use [PATCH RESEND] when your patch is different from the version you sent before. Please use [PATCH v2] instead.

Got it.

Quoted 14 lines
Quoted 4 lines

unsynchronized_tsc() checks value of tsc_clocksource_reliable which is set by check_system_tsc_reliable(). It's better to move check_system_tsc_reliable() at front.

Please make your statements affirmative. 'It's better' is a weak expression.

Quoted 2 lines

Though X86_FEATURE_CONSTANT_TSC is usually set for TSC reliable system, just in case.

So what you wanted to say here is:

tsc_clocksource_reliable is initialized in check_system_tsc_reliable(), but it is checked in unsynchronized_tsc() which is called before the initialization.

Quoted 5 lines

In practice that's not an issue because systems which mark the TSC reliable have X86_FEATURE_CONSTANT_TSC set as well, which is evaluated in unsynchronized_tsc() before tsc_clocksource_reliable.

Reorder the calls so initialization happens before usage.

Exactly.

Quoted 2 lines

All this information is also documented in Documentation/process/.

I'll read them.

Quoted 2 lines

No need to resend. I'll fix it up for you this time.

Ok, thanks.

zduan

#3 lore raw

[tip:x86/timers] x86/tsc: Call check_system_tsc_reliable() before unsynchronized_tsc()

In reply to Zhenzhong Duan
x86/tsc: Call check_system_tsc_reliable() before unsynchronized_tsc()
Commit-ID:  a1272dd5531b259bf7313ac7597a67362698038c
Gitweb:     http://git.kernel.org/tip/a1272dd5531b259bf7313ac7597a67362698038c
Author:     Zhenzhong Duan <[email protected]>
AuthorDate: Wed, 21 Jun 2017 01:23:37 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 22 Jun 2017 16:00:03 +0200

x86/tsc: Call check_system_tsc_reliable() before unsynchronized_tsc()

tsc_clocksource_reliable is initialized in check_system_tsc_reliable(), but it is checked in unsynchronized_tsc() which is called before the initialization.

In practice that's not an issue because systems which mark the TSC reliable have X86_FEATURE_CONSTANT_TSC set as well, which is evaluated in unsynchronized_tsc() before tsc_clocksource_reliable.

Reorder the calls so initialization happens before usage.

[ tglx: Massaged changelog ]

---
 arch/x86/kernel/tsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/tsc.c +2 -2
index 714dfba..a316bdd 100644
@@ -1412,11 +1412,11 @@ void __init tsc_init(void)
 
 	use_tsc_delay();
 
+	check_system_tsc_reliable();
+
 	if (unsynchronized_tsc())
 		mark_tsc_unstable("TSCs unsynchronized");
 
-	check_system_tsc_reliable();
-
 	detect_art();
 }