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
This commit is contained in:
parent
324150d6da
commit
9cb3288287
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user