TSC Timecounter and multi-core/SMP

David O'Brien obrien at freebsd.org
Fri Apr 18 00:32:20 UTC 2008


On Fri, Apr 11, 2008 at 08:34:29AM -0400, Andrew Gallatin wrote:
> gnn at freebsd.org writes:
>  > Howdy,
>  > 
>  > Is the TSC timecounter synchronized across multiple cores and/or
>  > processors?  A quick search seems to indicate it's not but I'd like to
>  > find a definitive reference on the TSC.
> 
> There is a great comment in the OpenSolaris source code talking about
> TSCs and their behavior on SMP systems.  See
> http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/i86pc/os/timestamp.c
> 
> FWIW, solaris manages to keep track of unsynchronized TSCs, and use
> unsynchronized TSC timecounters for timekeeping on SMP systems.  It
> would be nice if FreeBSD could do the same.

This only works for systems with an invariant TSC.  That is Solaris keeps
a per-CPU(core) TSC delta that is applied when the TSC is read from that
CPU(core).  I agree this would be a nice feature to have.  Linux sorely
needs it too.

This breaks down if the TSC's are not P-state invariant.  Which is why
Solaris does not support PowerNow! on K8's.  But running K8's at their
max speed, Solaris achieves an invariant TSC.

AMD processors make no guarantees about TSC values being synced across
processors (or Cores of a processor).  This is true for K7, K8, and
Greyhound (Family 10h).

The TSC on K8 is not invariant - its rate of change is affected by
P-state changes.

The TSC on Greyhound (Family 10h) is invariant.
[but as stated above, is not synced with other cores]

-- 
-- David  (obrien at FreeBSD.org)


More information about the freebsd-current mailing list