x86/time: adjust time recording in time_calibration_tsc_rendezvous()
authorJan Beulich <jbeulich@suse.com>
Fri, 19 Feb 2021 16:21:12 +0000 (17:21 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Feb 2021 16:21:12 +0000 (17:21 +0100)
commita2639824e8458a8f3826e184081a13bfa27ea884
treed58359802fde1283bbe9665ee901f6c5e52bb4ef
parentf954a1bf5f74ad6edce361d1bf1a29137ff374e8
x86/time: adjust time recording in time_calibration_tsc_rendezvous()

The (stime,tsc) tuple is the basis for extrapolation by get_s_time().
Therefore the two better get taken as close to one another as possible.
This means two things: First, reading platform time is too early when
done on the first iteration. The closest we can get is on the last
iteration, immediately before telling other CPUs to write their TSCs
(and then also writing CPU0's). While at the first glance it may seem
not overly relevant when exactly platform time is read (when assuming
that only stime is ever relevant anywhere, and hence the association
with the precise TSC values is of lower interest), both CPU frequency
changes and the effects of SMT make it unpredictable (between individual
rendezvous instances) how long the loop iterations will take. This will
in turn lead to higher an error than neccesary in how close to linear
stime movement we can get.

Second, re-reading the TSC for local recording is increasing the overall
error as well, when we already know a more precise value - the one just
written.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/x86/time.c