Re: TSC calibration in virtual machines

From: Jung-uk Kim <jkim_at_FreeBSD.org>
Date: Wed, 27 Jun 2018 13:10:49 -0400
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


Received on Wed Jun 27 2018 - 15:10:55 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:16 UTC