Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 Fix TSC drift is observed almost every time...
details: https://anonhg.NetBSD.org/src/rev/b9570da6b19b
branches: trunk
changeset: 746507:b9570da6b19b
user: knakahara <knakahara%NetBSD.org@localhost>
date: Fri Apr 03 03:05:39 2020 +0000
description:
Fix TSC drift is observed almost every time wrongly.
Ths "TSC drift" in tsc_tc_init() means the cpu_cc_skew delta between
first measurement (in cpu_start_secondary) and second measurement
(in cpu_boot_secondary), that is, the TSC drift is expected to be
almost zero. However, the second measument in current implementation
is added extra cpu_cc_skew accidentally, so current delta value means
almost cpu_cc_skew wrongly.
tsc_sync_bp and tsc_sync_ap should use rdtsc() to get raw values.
Advised by nonaka@n.o, thanks.
diffstat:
sys/arch/x86/x86/tsc.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diffs (48 lines):
diff -r 813d75bfab13 -r b9570da6b19b sys/arch/x86/x86/tsc.c
--- a/sys/arch/x86/x86/tsc.c Thu Apr 02 21:36:03 2020 +0000
+++ b/sys/arch/x86/x86/tsc.c Fri Apr 03 03:05:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tsc.c,v 1.38 2020/02/21 00:26:22 joerg Exp $ */
+/* $NetBSD: tsc.c,v 1.39 2020/04/03 03:05:39 knakahara Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.38 2020/02/21 00:26:22 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.39 2020/04/03 03:05:39 knakahara Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -201,13 +201,13 @@
/* Flag it and read our TSC. */
atomic_or_uint(&ci->ci_flags, CPUF_SYNCTSC);
- bptsc = cpu_counter_serializing() >> 1;
+ bptsc = (rdtsc() >> 1);
/* Wait for remote to complete, and read ours again. */
while ((ci->ci_flags & CPUF_SYNCTSC) != 0) {
__insn_barrier();
}
- bptsc += (cpu_counter_serializing() >> 1);
+ bptsc += (rdtsc() >> 1);
/* Wait for the results to come in. */
while (tsc_sync_cpu == ci) {
@@ -246,11 +246,11 @@
while ((ci->ci_flags & CPUF_SYNCTSC) == 0) {
__insn_barrier();
}
- tsc = (cpu_counter_serializing() >> 1);
+ tsc = (rdtsc() >> 1);
/* Instruct primary to read its counter. */
atomic_and_uint(&ci->ci_flags, ~CPUF_SYNCTSC);
- tsc += (cpu_counter_serializing() >> 1);
+ tsc += (rdtsc() >> 1);
/* Post result. Ensure the whole value goes out atomically. */
(void)atomic_swap_64(&tsc_sync_val, tsc);
Home |
Main Index |
Thread Index |
Old Index