x86/hyper-v: enable TSC page clocksource on 32bit
Subsystems (4)
PATCH v2 1/1 x86/hyper-v: enable TSC page clocksource on 32bit
There is no particular reason to not enable TSC page clocksource on 32-bit. mul_u64_u64_shr() is available and despite the increased computational complexity (compared to 64bit) TSC page is still a huge win compared to MSR-based clocksource.
In-kernel reads:
MSR based clocksource: 3361 cycles
TSC page clocksource: 49 cycles
Reads from userspace (utilizing vDSO in case of TSC page):
MSR based clocksource: 5664 cycles
TSC page clocksource: 131 cycles
Enabling TSC page on 32bits allows to get rid of CONFIG_HYPERV_TSCPAGE as it is now not any different from CONFIG_HYPERV_TIMER.
---
Changes since v1:
- Fix a couple of nits in changelog [Michael Kelley, Thomas Gleixner]
- Fixed a comment with CONFIG_HYPERV_TSC_PAGE [Michael Kelley]
- Added Michael's Reviewed-by: tag
- Rebased on timers/core [Thomas Gleixner]
--- arch/x86/include/asm/vdso/gettimeofday.h | 6 +++--- drivers/clocksource/hyperv_timer.c | 11 ----------- drivers/hv/Kconfig | 3 --- include/clocksource/hyperv_timer.h | 8 +++----- 4 files changed, 6 insertions(+), 22 deletions(-)
arch/x86/include/asm/vdso/gettimeofday.h +3 -3
@@ -51,7 +51,7 @@ extern struct pvclock_vsyscall_time_info pvclock_page __attribute__((visibility("hidden")));#endif -#ifdef CONFIG_HYPERV_TSCPAGE +#ifdef CONFIG_HYPERV_TIMER extern struct ms_hyperv_tsc_page hvclock_page __attribute__((visibility("hidden")));#endif
@@ -192,7 +192,7 @@ static u64 vread_pvclock(void) }#endif -#ifdef CONFIG_HYPERV_TSCPAGE +#ifdef CONFIG_HYPERV_TIMER static u64 vread_hvclock (void ) {return hv_read_tsc_page (&hvclock_page);
@@ -215,7 +215,7 @@ static inline u64 __arch_get_hw_counter(s32 clock_mode)return vread_pvclock (); }#endif -#ifdef CONFIG_HYPERV_TSCPAGE +#ifdef CONFIG_HYPERV_TIMER if (clock_mode ==VCLOCK_HVCLOCK ) {barrier ();return vread_hvclock ();
drivers/clocksource/hyperv_timer.c +0 -11
@@ -212,8 +212,6 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);struct clocksource *hyperv_cs;EXPORT_SYMBOL_GPL (hyperv_cs); -#ifdef CONFIG_HYPERV_TSCPAGE -static struct ms_hyperv_tsc_page tsc_pg__aligned(PAGE_SIZE) ;static u64 hv_sched_clock_offset__ro_after_init ;
@@ -245,7 +243,6 @@ static struct clocksource hyperv_cs_tsc = { .mask = CLOCKSOURCE_MASK(64), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; -#endif static u64 notrace read_hv_clock_msr(struct clocksource *arg) {
@@ -272,7 +269,6 @@ static struct clocksource hyperv_cs_msr = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; -#ifdef CONFIG_HYPERV_TSCPAGE static bool __init hv_init_tsc_clocksource (void ) {u64 tsc_msr;
@@ -304,13 +300,6 @@ static bool __init hv_init_tsc_clocksource(void)return true; } -#else -static bool __init hv_init_tsc_clocksource (void ) -{ -return false; -} -#endif -void __init hv_init_clocksource (void ) {
drivers/hv/Kconfig +0 -3
@@ -14,9 +14,6 @@ config HYPERV config HYPERV_TIMER def_bool HYPERV -config HYPERV_TSCPAGE - def_bool HYPERV && X86_64 - config HYPERV_UTILS tristate "Microsoft Hyper-V Utilities driver" depends on HYPERV && CONNECTOR && NLS
include/clocksource/hyperv_timer.h +3 -5
@@ -28,12 +28,10 @@ extern void hv_stimer_cleanup(unsigned int cpu);extern void hv_stimer_global_cleanup (void );extern void hv_stimer0_isr (void ); -#if IS_ENABLED (CONFIG_HYPERV ) +#ifdef CONFIG_HYPERV_TIMER extern struct clocksource *hyperv_cs;extern void hv_init_clocksource (void ); -#endif /* CONFIG_HYPERV */ -#ifdef CONFIG_HYPERV_TSCPAGE extern struct ms_hyperv_tsc_page *hv_get_tsc_page (void );static inline notrace u64
@@ -91,7 +89,7 @@ hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg) return hv_read_tsc_page_tsc(tsc_pg, &cur_tsc); } -#else /* CONFIG_HYPERV_TSC_PAGE */ +#else /* CONFIG_HYPERV_TIMER */ static inline struct ms_hyperv_tsc_page *hv_get_tsc_page (void ) {return NULL ;
@@ -102,6 +100,6 @@ static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg, {return U64_MAX ; } -#endif /* CONFIG_HYPERV_TSCPAGE */ +#endif /* CONFIG_HYPERV_TIMER */ #endif
Signature · 1 line
2.20.1
[tip: timers/core] clocksource/drivers/hyperv: Enable TSC page clocksource on 32bit
The following commit has been merged into the timers/core branch of tip:
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 3e2d94535adb2df15f3907e4b4c7cd8a5a4c2b5a Gitweb: https://git.kernel.org/tip/3e2d94535adb2df15f3907e4b4c7cd8a5a4c2b5a Author: Vitaly Kuznetsov <[email protected]> AuthorDate: Thu, 22 Aug 2019 10:36:30 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Fri, 23 Aug 2019 16:59:54 +02:00
clocksource/drivers/hyperv: Enable TSC page clocksource on 32bit
There is no particular reason to not enable TSC page clocksource on 32-bit. mul_u64_u64_shr() is available and despite the increased computational complexity (compared to 64bit) TSC page is still a huge win compared to MSR-based clocksource.
In-kernel reads:
MSR based clocksource: 3361 cycles
TSC page clocksource: 49 cycles
Reads from userspace (utilizing vDSO in case of TSC page):
MSR based clocksource: 5664 cycles
TSC page clocksource: 131 cycles
Enabling TSC page on 32bits allows to get rid of CONFIG_HYPERV_TSCPAGE as it is now not any different from CONFIG_HYPERV_TIMER.
--- arch/x86/include/asm/vdso/gettimeofday.h | 6 +++--- drivers/clocksource/hyperv_timer.c | 11 ----------- drivers/hv/Kconfig | 3 --- include/clocksource/hyperv_timer.h | 8 +++----- 4 files changed, 6 insertions(+), 22 deletions(-)
arch/x86/include/asm/vdso/gettimeofday.h +3 -3
@@ -51,7 +51,7 @@ extern struct pvclock_vsyscall_time_info pvclock_page __attribute__((visibility("hidden")));#endif -#ifdef CONFIG_HYPERV_TSCPAGE +#ifdef CONFIG_HYPERV_TIMER extern struct ms_hyperv_tsc_page hvclock_page __attribute__((visibility("hidden")));#endif
@@ -192,7 +192,7 @@ static u64 vread_pvclock(void) }#endif -#ifdef CONFIG_HYPERV_TSCPAGE +#ifdef CONFIG_HYPERV_TIMER static u64 vread_hvclock (void ) {return hv_read_tsc_page (&hvclock_page);
@@ -215,7 +215,7 @@ static inline u64 __arch_get_hw_counter(s32 clock_mode)return vread_pvclock (); }#endif -#ifdef CONFIG_HYPERV_TSCPAGE +#ifdef CONFIG_HYPERV_TIMER if (clock_mode ==VCLOCK_HVCLOCK ) {barrier ();return vread_hvclock ();
drivers/clocksource/hyperv_timer.c +0 -11
@@ -213,8 +213,6 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);struct clocksource *hyperv_cs;EXPORT_SYMBOL_GPL (hyperv_cs); -#ifdef CONFIG_HYPERV_TSCPAGE -static struct ms_hyperv_tsc_page tsc_pg__aligned(PAGE_SIZE) ;struct ms_hyperv_tsc_page *hv_get_tsc_page (void )
@@ -245,7 +243,6 @@ static struct clocksource hyperv_cs_tsc = { .mask = CLOCKSOURCE_MASK(64), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; -#endif static u64 notrace read_hv_clock_msr(struct clocksource *arg) {
@@ -272,7 +269,6 @@ static struct clocksource hyperv_cs_msr = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; -#ifdef CONFIG_HYPERV_TSCPAGE static bool __init hv_init_tsc_clocksource (void ) {u64 tsc_msr;
@@ -304,13 +300,6 @@ static bool __init hv_init_tsc_clocksource(void)return true; } -#else -static bool __init hv_init_tsc_clocksource (void ) -{ -return false; -} -#endif -void __init hv_init_clocksource (void ) {
drivers/hv/Kconfig +0 -3
@@ -14,9 +14,6 @@ config HYPERV config HYPERV_TIMER def_bool HYPERV -config HYPERV_TSCPAGE - def_bool HYPERV && X86_64 - config HYPERV_UTILS tristate "Microsoft Hyper-V Utilities driver" depends on HYPERV && CONNECTOR && NLS
include/clocksource/hyperv_timer.h +3 -5
@@ -28,12 +28,10 @@ extern void hv_stimer_cleanup(unsigned int cpu);extern void hv_stimer_global_cleanup (void );extern void hv_stimer0_isr (void ); -#if IS_ENABLED (CONFIG_HYPERV ) +#ifdef CONFIG_HYPERV_TIMER extern struct clocksource *hyperv_cs;extern void hv_init_clocksource (void ); -#endif /* CONFIG_HYPERV */ -#ifdef CONFIG_HYPERV_TSCPAGE extern struct ms_hyperv_tsc_page *hv_get_tsc_page (void );static inline notrace u64
@@ -91,7 +89,7 @@ hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg) return hv_read_tsc_page_tsc(tsc_pg, &cur_tsc); } -#else /* CONFIG_HYPERV_TSC_PAGE */ +#else /* CONFIG_HYPERV_TIMER */ static inline struct ms_hyperv_tsc_page *hv_get_tsc_page (void ) {return NULL ;
@@ -102,6 +100,6 @@ static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg, {return U64_MAX ; } -#endif /* CONFIG_HYPERV_TSCPAGE */ +#endif /* CONFIG_HYPERV_TIMER */ #endif