Skip to content

Commit 3e2d945

Browse files
vittyvkKAGA-KOKO
authored andcommitted
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. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lkml.kernel.org/r/20190822083630.17059-1-vkuznets@redhat.com
1 parent bd00cd5 commit 3e2d945

4 files changed

Lines changed: 6 additions & 22 deletions

File tree

‎arch/x86/include/asm/vdso/gettimeofday.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extern struct pvclock_vsyscall_time_info pvclock_page
5151
__attribute__((visibility("hidden")));
5252
#endif
5353

54-
#ifdef CONFIG_HYPERV_TSCPAGE
54+
#ifdef CONFIG_HYPERV_TIMER
5555
extern struct ms_hyperv_tsc_page hvclock_page
5656
__attribute__((visibility("hidden")));
5757
#endif
@@ -192,7 +192,7 @@ static u64 vread_pvclock(void)
192192
}
193193
#endif
194194

195-
#ifdef CONFIG_HYPERV_TSCPAGE
195+
#ifdef CONFIG_HYPERV_TIMER
196196
static u64 vread_hvclock(void)
197197
{
198198
return hv_read_tsc_page(&hvclock_page);
@@ -215,7 +215,7 @@ static inline u64 __arch_get_hw_counter(s32 clock_mode)
215215
return vread_pvclock();
216216
}
217217
#endif
218-
#ifdef CONFIG_HYPERV_TSCPAGE
218+
#ifdef CONFIG_HYPERV_TIMER
219219
if (clock_mode == VCLOCK_HVCLOCK) {
220220
barrier();
221221
return vread_hvclock();

‎drivers/clocksource/hyperv_timer.c‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);
213213
struct clocksource *hyperv_cs;
214214
EXPORT_SYMBOL_GPL(hyperv_cs);
215215

216-
#ifdef CONFIG_HYPERV_TSCPAGE
217-
218216
static struct ms_hyperv_tsc_page tsc_pg __aligned(PAGE_SIZE);
219217

220218
struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
@@ -245,7 +243,6 @@ static struct clocksource hyperv_cs_tsc = {
245243
.mask = CLOCKSOURCE_MASK(64),
246244
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
247245
};
248-
#endif
249246

250247
static u64 notrace read_hv_clock_msr(struct clocksource *arg)
251248
{
@@ -272,7 +269,6 @@ static struct clocksource hyperv_cs_msr = {
272269
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
273270
};
274271

275-
#ifdef CONFIG_HYPERV_TSCPAGE
276272
static bool __init hv_init_tsc_clocksource(void)
277273
{
278274
u64 tsc_msr;
@@ -304,13 +300,6 @@ static bool __init hv_init_tsc_clocksource(void)
304300

305301
return true;
306302
}
307-
#else
308-
static bool __init hv_init_tsc_clocksource(void)
309-
{
310-
return false;
311-
}
312-
#endif
313-
314303

315304
void __init hv_init_clocksource(void)
316305
{

‎drivers/hv/Kconfig‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ config HYPERV
1414
config HYPERV_TIMER
1515
def_bool HYPERV
1616

17-
config HYPERV_TSCPAGE
18-
def_bool HYPERV && X86_64
19-
2017
config HYPERV_UTILS
2118
tristate "Microsoft Hyper-V Utilities driver"
2219
depends on HYPERV && CONNECTOR && NLS

‎include/clocksource/hyperv_timer.h‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ extern void hv_stimer_cleanup(unsigned int cpu);
2828
extern void hv_stimer_global_cleanup(void);
2929
extern void hv_stimer0_isr(void);
3030

31-
#if IS_ENABLED(CONFIG_HYPERV)
31+
#ifdef CONFIG_HYPERV_TIMER
3232
extern struct clocksource *hyperv_cs;
3333
extern void hv_init_clocksource(void);
34-
#endif /* CONFIG_HYPERV */
3534

36-
#ifdef CONFIG_HYPERV_TSCPAGE
3735
extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void);
3836

3937
static inline notrace u64
@@ -91,7 +89,7 @@ hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg)
9189
return hv_read_tsc_page_tsc(tsc_pg, &cur_tsc);
9290
}
9391

94-
#else /* CONFIG_HYPERV_TSC_PAGE */
92+
#else /* CONFIG_HYPERV_TIMER */
9593
static inline struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
9694
{
9795
return NULL;
@@ -102,6 +100,6 @@ static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg,
102100
{
103101
return U64_MAX;
104102
}
105-
#endif /* CONFIG_HYPERV_TSCPAGE */
103+
#endif /* CONFIG_HYPERV_TIMER */
106104

107105
#endif

0 commit comments

Comments
 (0)