[LinuxPPS] [PATCH 01/11] PPS: Don't waste time getting unnecessary timestamps.

Rodolfo Giometti giometti at enneenne.com
Tue Feb 10 09:02:11 CET 2009


On Mon, Feb 09, 2009 at 08:00:48PM -0500, George Spelvin wrote:
> 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.

Not all architectures (still) support it.

> 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.)

Mmm... I suppose using likely() could be better... let me investigate.

> 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;

Better form! :)

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti



More information about the LinuxPPS mailing list