Skip to contentSkip to conversation

hyper-v: mark TSC as unstable

PATCH In review Vitaly Kuznetsov 4 participants 4 messages Aug 19, 2015 – Aug 21, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hyper-v: mark TSC as unstable

Hyper-V top-level functional specification states, that "algorithms should be resilient to sudden jumps forward or backward in the TSC value", this means that we should consider TSC as unstable. In some cases tsc tests are able to detect the instability, it was detected in 543 out of 646 boots in my testing:

Measured 6277 cycles TSC warp between CPUs, turning off TSC clock.
tsc: Marking TSC unstable due to check_tsc_sync_source failed

This is, however, just a heuristic. On Hyper-V platform there are two good
clocksources: MSR-based hyperv_clocksource and recently introduced TSC page.

---
 arch/x86/kernel/cpu/mshyperv.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/cpu/mshyperv.c +1 -0
index aad4bd8..6fd023d 100644
@@ -141,6 +141,7 @@ static void __init ms_hyperv_init_platform(void)
 	no_timer_check = 1;
 #endif
 
+	mark_tsc_unstable("running on Hyper-V");
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
Signature · 1 line
2.4.3
#1 lore raw

[tip:x86/platform] x86/hyperv: Mark the Hyper-V TSC as unstable

x86/hyperv: Mark the Hyper-V TSC as unstable
Commit-ID:  88c9281a9fba67636ab26c1fd6afbc78a632374f
Gitweb:     http://git.kernel.org/tip/88c9281a9fba67636ab26c1fd6afbc78a632374f
Author:     Vitaly Kuznetsov <[email protected]>
AuthorDate: Wed, 19 Aug 2015 09:54:24 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 21 Aug 2015 08:44:38 +0200

x86/hyperv: Mark the Hyper-V TSC as unstable

The Hyper-V top-level functional specification states, that "algorithms should be resilient to sudden jumps forward or backward in the TSC value", this means that we should consider TSC as unstable. In some cases tsc tests are able to detect the instability, it was detected in 543 out of 646 boots in my testing:

Measured 6277 cycles TSC warp between CPUs, turning off TSC clock.
tsc: Marking TSC unstable due to check_tsc_sync_source failed

This is, however, just a heuristic. On Hyper-V platform there are two good clocksources: MSR-based hyperv_clocksource and recently introduced TSC page.

---
 arch/x86/kernel/cpu/mshyperv.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/cpu/mshyperv.c +1 -0
index aad4bd8..6fd023d 100644
@@ -141,6 +141,7 @@ static void __init ms_hyperv_init_platform(void)
 	no_timer_check = 1;
 #endif
 
+	mark_tsc_unstable("running on Hyper-V");
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
#2 lore raw

Re: [tip:x86/platform] x86/hyperv: Mark the Hyper-V TSC as unstable

Quoted 16 lines · tip-bot for Vitaly Kuznetsov
Commit-ID:  88c9281a9fba67636ab26c1fd6afbc78a632374f
Gitweb:     http://git.kernel.org/tip/88c9281a9fba67636ab26c1fd6afbc78a632374f
Author:     Vitaly Kuznetsov <[email protected]>
AuthorDate: Wed, 19 Aug 2015 09:54:24 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 21 Aug 2015 08:44:38 +0200

x86/hyperv: Mark the Hyper-V TSC as unstable

The Hyper-V top-level functional specification states, that "algorithms should be resilient to sudden jumps forward or backward in the TSC value", this means that we should consider TSC as unstable. In some cases tsc tests are able to detect the instability, it was detected in 543 out of 646 boots in my testing:

Quoted 6 lines

Measured 6277 cycles TSC warp between CPUs, turning off TSC clock.
tsc: Marking TSC unstable due to check_tsc_sync_source failed

This is, however, just a heuristic. On Hyper-V platform there are two good clocksources: MSR-based hyperv_clocksource and recently introduced TSC page.

*groan*.. and where are the paravirt ops like pv_time_ops for hyperv to fix up this mess?

#3 lore raw

RE: [tip:x86/platform] x86/hyperv: Mark the Hyper-V TSC as unstable

Quoted 38 lines

-----Original Message-----
From: Peter Zijlstra [mailto:[email protected]]
Sent: Friday, August 21, 2015 7:34 AM
To: [email protected]; Haiyang Zhang <[email protected]>; [email protected]; [email protected]; [email protected]; KY Srinivasan <[email protected]>; [email protected]; linux- [email protected]
Cc: [email protected]
Subject: Re: [tip:x86/platform] x86/hyperv: Mark the Hyper-V TSC as unstable

Quoted 2 lines · tip-bot for Vitaly Kuznetsov

Commit-ID: 88c9281a9fba67636ab26c1fd6afbc78a632374f Gitweb:

https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fgit.kern
el.org%2ftip%2f88c9281a9fba67636ab26c1fd6afbc78a632374f&data=01%7c01 %7ckys%40microsoft.com%7cca840f9ebba34958dc9a08d2aa35a6c4%7c72f988 bf86f141af91ab2d7cd011db47%7c1&sdata=hzE233wXaLAYShWPE18SQJQvQe JguAdB6oj%2bF%2blx7Ok%3d

Quoted 17 lines
Author:     Vitaly Kuznetsov <[email protected]>
AuthorDate: Wed, 19 Aug 2015 09:54:24 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 21 Aug 2015 08:44:38 +0200

x86/hyperv: Mark the Hyper-V TSC as unstable

The Hyper-V top-level functional specification states, that "algorithms should be resilient to sudden jumps forward or backward in the TSC value", this means that we should consider TSC as unstable. In some cases tsc tests are able to detect the instability, it was detected in 543 out of 646 boots in my testing:

Measured 6277 cycles TSC warp between CPUs, turning off TSC clock.
tsc: Marking TSC unstable due to check_tsc_sync_source failed

Quoted 6 lines
Quoted 3 lines

This is, however, just a heuristic. On Hyper-V platform there are two good clocksources: MSR-based hyperv_clocksource and recently introduced TSC page.

*groan*.. and where are the paravirt ops like pv_time_ops for hyperv to fix up this mess?

We register external clocksource and clockevents devices based on a hypervisor based time source and timers to deal with this issue.

Regards,

K. Y