Re: 2.6.15:kernel/time.c: The Nanosecond and code duplication

From: Christoph Lameter
Date: Mon Feb 13 2006 - 16:09:25 EST


On Mon, 13 Feb 2006, Ulrich Windl wrote:

> There's a hacked-on getnstimeofday() which, what I discovered doesn't actually
> pass along the nanosecond resolution of xtime. It does:

This is the fall back function for arches without nanosecond
resolution....

> The proper solution most likely is to define POSIX compatible routines with
> nanosecond resolution, and then define the microsecond-resolution from those, and
> not the other way round.

Right.

> -#ifdef CONFIG_TIME_INTERPOLATION
> +/* get system time with nanosecond accuracy */
> void getnstimeofday (struct timespec *tv)
> {
> - unsigned long seq,sec,nsec;
> -
> + unsigned long seq, nsec, sec, offset;
> do {
> seq = read_seqbegin(&xtime_lock);
> +#ifdef CONFIG_TIME_INTERPOLATION
> + offset = time_interpolator_get_offset();
> +#else
> + offset = 0;
> +#endif
> sec = xtime.tv_sec;
> - nsec = xtime.tv_nsec+time_interpolator_get_offset();
> + nsec = xtime.tv_nsec + offset;
> } while (unlikely(read_seqretry(&xtime_lock, seq)));
>
> +#ifdef CONFIG_TIME_INTERPOLATION
> while (unlikely(nsec >= NSEC_PER_SEC)) {
> nsec -= NSEC_PER_SEC;
> ++sec;
> }
> +#endif
> tv->tv_sec = sec;
> tv->tv_nsec = nsec;
> }
> EXPORT_SYMBOL_GPL(getnstimeofday);

Looks okay.

> +#ifdef CONFIG_TIME_INTERPOLATION
> +/* this is a mess: there are also architecture-dependent ``do_gettimeofday()''
> + * and ``do_settimeofday()''
> + */

Yes, we would like to get rid of the arch specific
do_get/settimeofday() in the future.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/