Thus far, just basic testing on top of QEMU 4.2.1 + kernel 5.8.0 on Ubuntu 20.04 on Intel and AMD HW via:
- `date`
- `syscall_timing`
- `sysctl`s `debug.clock_show_io`, `debug.clock_do_io`, `kern.timecounter.hardware`, and `kern.timecounter.fast_gettime`
- Using `dtrace` to sanity-check that `sys_gettimeofday()`/`sys_clock_gettime()` were/weren't being called as expected.
- `zzz(8)` plus the QEMU `system_powerdown` and `system_wakeup` commands (for test-driving the suspend/resume entry points).
I also tried the `sysbench` invocation in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216759#c11 and can confirm similar differences between using the `HPET` and using the `kvmclock` or `TSC`.
An example including some timing info:
```
user@test:~ % sysctl kern.timecounter
kern.timecounter.tsc_shift: 1
kern.timecounter.smp_tsc_adjust: 0
kern.timecounter.smp_tsc: 0
kern.timecounter.invariant_tsc: 0
kern.timecounter.fast_gettime: 1
kern.timecounter.tick: 1
kern.timecounter.choice: i8254(0) ACPI-fast(900) HPET(950) kvmclock(975) TSC(-100) dummy(-1000000)
kern.timecounter.hardware: kvmclock
kern.timecounter.alloweddeviation: 5
kern.timecounter.timehands_count: 2
kern.timecounter.stepwarnings: 0
kern.timecounter.tc.i8254.quality: 0
kern.timecounter.tc.i8254.frequency: 1193182
kern.timecounter.tc.i8254.counter: 59794
kern.timecounter.tc.i8254.mask: 65535
kern.timecounter.tc.ACPI-fast.quality: 900
kern.timecounter.tc.ACPI-fast.frequency: 3579545
kern.timecounter.tc.ACPI-fast.counter: 3543295
kern.timecounter.tc.ACPI-fast.mask: 16777215
kern.timecounter.tc.HPET.quality: 950
kern.timecounter.tc.HPET.frequency: 100000000
kern.timecounter.tc.HPET.counter: 1966409884
kern.timecounter.tc.HPET.mask: 4294967295
kern.timecounter.tc.kvmclock.quality: 975
kern.timecounter.tc.kvmclock.frequency: 1000000000
kern.timecounter.tc.kvmclock.counter: 3373140415
kern.timecounter.tc.kvmclock.mask: 4294967295
kern.timecounter.tc.TSC.quality: -100
kern.timecounter.tc.TSC.frequency: 1607988965
kern.timecounter.tc.TSC.counter: 513410333
kern.timecounter.tc.TSC.mask: 4294967295
user@test:~ % syscall_timing gettimeofday
Clock resolution: 0.000000002
test loop time iterations periteration
gettimeofday 0 1.000971171 24698568 0.000000040
gettimeofday 1 1.007769518 24866552 0.000000040
gettimeofday 2 1.001071247 24700412 0.000000040
gettimeofday 3 1.006630289 24832878 0.000000040
gettimeofday 4 1.003202891 24769714 0.000000040
gettimeofday 5 1.004513069 24790162 0.000000040
gettimeofday 6 1.005332074 24833956 0.000000040
gettimeofday 7 1.002384739 24735470 0.000000040
gettimeofday 8 1.007455964 24884169 0.000000040
gettimeofday 9 1.000256110 24708625 0.000000040
user@test:~ % sudo sysctl kern.timecounter.fast_gettime=0
kern.timecounter.fast_gettime: 1 -> 0
user@test:~ % syscall_timing gettimeofday
Clock resolution: 0.000000002
test loop time iterations periteration
gettimeofday 0 1.062566203 8546464 0.000000124
gettimeofday 1 1.037318670 8305737 0.000000124
gettimeofday 2 1.050000947 8410842 0.000000124
gettimeofday 3 1.049828515 8405755 0.000000124
gettimeofday 4 1.062561943 8522758 0.000000124
gettimeofday 5 1.037252041 8295647 0.000000125
gettimeofday 6 1.009902776 8103514 0.000000124
gettimeofday 7 1.029863208 8271323 0.000000124
gettimeofday 8 1.059883267 8462669 0.000000125
gettimeofday 9 1.009913686 8092699 0.000000124
user@test:~ % sudo sysctl kern.timecounter.fast_gettime=1
kern.timecounter.fast_gettime: 0 -> 1
user@test:~ % sudo sysctl kern.timecounter.hardware=TSC
kern.timecounter.hardware: kvmclock -> TSC
user@test:~ % syscall_timing gettimeofday
Clock resolution: 0.000000001
test loop time iterations periteration
gettimeofday 0 1.039693055 39156300 0.000000026
gettimeofday 1 1.059332059 39727049 0.000000026
gettimeofday 2 1.040353569 39121632 0.000000026
gettimeofday 3 1.050123063 39481224 0.000000026
gettimeofday 4 1.049670668 39530649 0.000000026
gettimeofday 5 1.062567179 39960000 0.000000026
gettimeofday 6 1.037282737 38908035 0.000000026
gettimeofday 7 1.062564063 39918185 0.000000026
gettimeofday 8 1.037147904 39045152 0.000000026
gettimeofday 9 1.009909895 38041308 0.000000026
user@test:~ % sudo sysctl kern.timecounter.fast_gettime=0
kern.timecounter.fast_gettime: 1 -> 0
user@test:~ % syscall_timing gettimeofday
Clock resolution: 0.000000001
test loop time iterations periteration
gettimeofday 0 1.000343476 9173210 0.000000109
gettimeofday 1 1.007733227 9233248 0.000000109
gettimeofday 2 1.051675824 9637613 0.000000109
gettimeofday 3 1.003205497 9195701 0.000000109
gettimeofday 4 1.006564792 9226628 0.000000109
gettimeofday 5 1.001095929 9169797 0.000000109
gettimeofday 6 1.007764181 9224751 0.000000109
gettimeofday 7 1.000836593 9169834 0.000000109
gettimeofday 8 1.006850768 9220051 0.000000109
gettimeofday 9 1.002965937 9190431 0.000000109
user@test:~ % sudo sysctl kern.timecounter.fast_gettime=1
kern.timecounter.fast_gettime: 0 -> 1
user@test:~ % sudo sysctl kern.timecounter.hardware=HPET
kern.timecounter.hardware: TSC -> HPET
user@test:~ % syscall_timing gettimeofday
Clock resolution: 0.000000011
test loop time iterations periteration
gettimeofday 0 1.001976650 361817 0.000002769
gettimeofday 1 1.007771340 363755 0.000002770
gettimeofday 2 1.007759790 364436 0.000002765
gettimeofday 3 1.002167610 361223 0.000002774
gettimeofday 4 1.005514150 363170 0.000002768
gettimeofday 5 1.004283770 363254 0.000002764
gettimeofday 6 1.003406260 361886 0.000002772
gettimeofday 7 1.006412230 362752 0.000002774
gettimeofday 8 1.049863580 378690 0.000002772
gettimeofday 9 1.006341930 363179 0.000002770
user@test:~ % sudo sysctl kern.timecounter.fast_gettime=0
kern.timecounter.fast_gettime: 1 -> 0
user@test:~ % syscall_timing gettimeofday
Clock resolution: 0.000000011
test loop time iterations periteration
gettimeofday 0 1.005940780 339403 0.000002963
gettimeofday 1 1.062578460 359351 0.000002956
gettimeofday 2 1.037196880 350767 0.000002956
gettimeofday 3 1.062579500 359486 0.000002955
gettimeofday 4 1.037203790 351224 0.000002953
gettimeofday 5 1.009921970 342757 0.000002946
gettimeofday 6 1.029915260 334432 0.000003079
gettimeofday 7 1.059815440 345772 0.000003065
gettimeofday 8 1.009940770 329601 0.000003064
gettimeofday 9 1.062575370 347237 0.000003060
user@test:~ % sudo sysctl kern.timecounter.fast_gettime=1
```