clock/tsc: Detect invariant TSC CPU synchronization
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 20 Jun 2013 03:10:03 +0000 (11:10 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 20 Jun 2013 03:25:39 +0000 (11:25 +0800)
commitdda44f1e92d93dc26b3445bdc61b11c3fda8733d
tree4d6498dad99b907bd244d70edf7a4693dd0c0a4a
parent12728eab9827bc13c9a8c54b6689788a3223cae3
clock/tsc: Detect invariant TSC CPU synchronization

The detected result could be used to determine whether TSC could be
used as cputimer or not, and could be used by other stuffs, e.g.
CoDel AQM packet time stamping.

- Only invariant TSC will be tested
- If there is only one CPU, then invariant TSC is always synchronized
- Only CPUs from Intel are tested (*)

The test is conducted using lwkt_cpusync interfaces:
BSP read the TSC, then ask APs to read TSC.  If TSC read from any APs
is less then the BSP's TSC, the invariant TSC is not synchronized
across CPUs.

Currently the test runs ~100ms.

(*)
AMD family 15h model 00h-0fh may also have synchronized TSC across
CPUs as pointed out by vsrinivas@, however, according to AMD:

  <Revision Guide for AMD Family 15h Models 00h-0Fh Processors
   Rev. 3.18 October 2012>
  759 One Core May Observe a Time Stamp Counter Skew

AMD family 15h model 00h-0fh is _not_ ready yet.
sys/platform/pc32/include/clock.h
sys/platform/pc32/isa/clock.c
sys/platform/pc64/include/clock.h
sys/platform/pc64/isa/clock.c
sys/platform/vkernel/include/clock.h
sys/platform/vkernel/platform/init.c
sys/platform/vkernel/platform/systimer.c
sys/platform/vkernel64/include/clock.h
sys/platform/vkernel64/platform/init.c
sys/platform/vkernel64/platform/systimer.c