x86/time: further improve TSC / CPU freq calibration accuracy
authorJan Beulich <jbeulich@suse.com>
Mon, 14 Mar 2022 09:27:57 +0000 (10:27 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 14 Mar 2022 09:27:57 +0000 (10:27 +0100)
commit23658e823238742dc5a17a0bac9f38c997dedd55
treec5f972920e415b4b0dbc2a097e99baf6b3e2831c
parent6ff9a7e62b8c43fe3e9d360fbd49d5854787bc39
x86/time: further improve TSC / CPU freq calibration accuracy

Calibration logic assumes that the platform timer (HPET or ACPI PM
timer) and the TSC are read at about the same time. This assumption may
not hold when a long latency event (e.g. SMI or NMI) occurs between the
two reads. Reduce the risk of reading uncorrelated values by doing at
least four pairs of reads, using the tuple where the delta between the
enclosing TSC reads was smallest. From the fourth iteration onwards bail
if the new TSC delta isn't better (smaller) than the best earlier one.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/time.c