aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2021-12-30 19:43:15 +0000
committerColin Percival <cperciva@FreeBSD.org>2022-01-02 21:07:53 +0000
commit9cb3288287ba1b3c1d0ec891c552fc4b9472027e (patch)
tree2d5460223e4b98859762fd6a41f6ae659fa21d50
parent324150d6dab8a5fcde98c6cc1869da0becb7c3bb (diff)
downloadsrc-9cb3288287ba1b3c1d0ec891c552fc4b9472027e.tar.gz
src-9cb3288287ba1b3c1d0ec891c552fc4b9472027e.zip
Skip TSC calibration if exact value known
It's possible that the "early" TSC calibration gave us a value which is known to be exact; in that case, skip the later re-calibration. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33695
-rw-r--r--sys/x86/x86/tsc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c
index ab8f94c2fc2d..534fdb5dd279 100644
--- a/sys/x86/x86/tsc.c
+++ b/sys/x86/x86/tsc.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
uint64_t tsc_freq;
int tsc_is_invariant;
int tsc_perf_stat;
+static int tsc_early_calib_exact;
static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag;
@@ -133,6 +134,7 @@ tsc_freq_vmware(void)
tsc_freq = regs[0] | ((uint64_t)regs[1] << 32);
}
tsc_is_invariant = 1;
+ tsc_early_calib_exact = 1;
}
/*
@@ -709,6 +711,8 @@ tsc_calibrate(void)
if (tsc_disabled)
return;
+ if (tsc_early_calib_exact)
+ goto calibrated;
tc = atomic_load_ptr(&timecounter);
@@ -739,6 +743,7 @@ tsc_calibrate(void)
freq_khz = tc->tc_frequency * (tsc_end - tsc_start) / (t_end - t_start);
tsc_update_freq(freq_khz);
+calibrated:
tc_init(&tsc_timecounter);
set_cputicker(rdtsc, tsc_freq, !tsc_is_invariant);
}