2017-06-21 08:23:52

by Zhenzhong Duan

[permalink] [raw]
Subject: [PATCH RESEND] 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.

Signed-off-by: Zhenzhong Duan <[email protected]>
---
arch/x86/kernel/tsc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 714dfba..a316bdd 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -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();
}

--
1.7.3


2017-06-22 13:57:41

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH RESEND] Calling check_system_tsc_reliable() before unsynchronized_tsc()

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.

> 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.

> 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

Subject: [tip:x86/timers] 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 ]

Signed-off-by: Zhenzhong Duan <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/b1532ef7-cd9f-45f7-9f49-48dd2a5c2495@default
---
arch/x86/kernel/tsc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 714dfba..a316bdd 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -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();
}


2017-06-23 08:30:48

by Zhenzhong Duan

[permalink] [raw]
Subject: Re: [PATCH RESEND] Calling check_system_tsc_reliable() before unsynchronized_tsc()

?? 2017/6/22 21:56, Thomas Gleixner ะด??:
> 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.
Got it.
>
>> 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.
>
>> 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.
Exactly.
>
> All this information is also documented in Documentation/process/.
I'll read them.
>
> No need to resend. I'll fix it up for you this time.
Ok, thanks.

zduan