git: 9cb3288287ba - main - Skip TSC calibration if exact value known
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 02 Jan 2022 21:08:08 UTC
The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=9cb3288287ba1b3c1d0ec891c552fc4b9472027e commit 9cb3288287ba1b3c1d0ec891c552fc4b9472027e Author: Colin Percival <cperciva@FreeBSD.org> AuthorDate: 2021-12-30 19:43:15 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2022-01-02 21:07:53 +0000 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 --- sys/x86/x86/tsc.c | 5 +++++ 1 file changed, 5 insertions(+) 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); }