[LinuxPPS] [PATCH 01/11] PPS: Don't waste time getting unnecessary timestamps.
George Spelvin
linux at horizon.com
Tue Feb 10 02:00:48 CET 2009
Rodolfo Giometti <giometti at enneenne.com> wrote:
> Nack.
>
> Function getnstimeofday() should be called as soon as possible since
> even a little delay may cause a large timing error! So is better
> calling getnstimeofday() even if not necessary then delay it.
My reasoning was that if you cared enough, you'd enable interrupt
timestamps; this is a fallback.
But really, one predicted untaken branch (forward branches are predicted
not taken if not in the prediction cache) is a truly negligible overhead.
(You can add a likely() hint to make the branch time deterministic.)
Far more critical is jitter, which is an issue becuase of the
possible looping inside getnstimeofday().
(/usr/src/linux/kernel/time/timekeeping.c)
If you don't like that, I'd at least simplify it to:
/* First of all we get the time stamp... */
getnstimeofday(&__ts);
- /* Does caller give us a timestamp? */
- if (ts) { /* Yes. Let's use it! */
- pps_ts.sec = ts->tv_sec;
- pps_ts.nsec = ts->tv_nsec;
- } else { /* No. Do it ourself! */
- pps_ts.sec = __ts.tv_sec;
- pps_ts.nsec = __ts.tv_nsec;
+ /* Do we need this timestamp or have we got one already? */
+ if (!ts)
+ ts = &__ts;
+ pps_ts.sec = ts->tv_sec;
+ pps_ts.nsec = ts->tv_nsec;
More information about the LinuxPPS
mailing list