TSC calibration in virtual machines
Jung-uk Kim
jkim at FreeBSD.org
Wed Jun 27 17:10:55 UTC 2018
On 06/27/2018 13:01, Ryan Stone wrote:
> I would guess that the calibration can fail because when running under
> the hypervisor, the FreeBSD guest code can be descheduled at the wrong
> time. As I recall, the current algorithm looks like:
>
> 1. Sample rdtsc
> 2. Use a fixed-frequency timer to busy-wait for exactly 1 second
> 3. Sample rdtsc again
> 4. tsc_freq = sample2 - sample1;
>
> If we are descheduled between 2 and 3, the time we spend off-cpu will
> not be accounted for at step 4. On bare-metal this is not possible as
> neither the scheduler nor interrupts are not running yet.
>
> Although, come to think of it, I seem to recall something about SMI
> interrupts mucking this up long in the past, for exactly the same
> reason.
I think it was legacy USB device emulation for certain Intel
chipset-based motherboards.
Jung-uk Kim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20180627/64addf87/attachment.sig>
More information about the freebsd-current
mailing list