x86/time: improve TSC / CPU freq calibration accuracy
authorJan Beulich <jbeulich@suse.com>
Thu, 13 Jan 2022 13:31:52 +0000 (14:31 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 13 Jan 2022 13:31:52 +0000 (14:31 +0100)
commita5c9a80af34eefcd6e31d0ed2b083f452cd9076d
tree48e32472f19d64e326b22571406461caa2625718
parent467191641d2a2fd2e43b3ae7b80399f89d339980
x86/time: improve TSC / CPU freq calibration accuracy

While the problem report was for extreme errors, even smaller ones would
better be avoided: The calculated period to run calibration loops over
can (and usually will) be shorter than the actual time elapsed between
first and last platform timer and TSC reads. Adjust values returned from
the init functions accordingly.

On a Skylake system I've tested this on accuracy (using HPET) went from
detecting in some cases more than 220kHz too high a value to about
±2kHz. On other systems (or on this system, but with PMTMR) the original
error range was much smaller, with less (in some cases only very little)
improvement.

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