Re: TSC Timecounter and multi-core/SMP

From: David O'Brien <obrien_at_freebsd.org>
Date: Thu, 17 Apr 2008 17:32:03 -0700
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)
Received on Thu Apr 17 2008 - 22:32:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:29 UTC