Re: + time-generic-timekeeping-infrastructure.patch added to -mmtree

From: Arjan van de Ven
Date: Wed Jan 04 2006 - 03:25:21 EST


On Tue, 2006-01-03 at 16:36 -0800, akpm@xxxxxxxx wrote:

>
> +static inline void normalize_timespec(struct timespec *ts)
> +{
> + while (unlikely((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)) {
> + ts->tv_nsec -= NSEC_PER_SEC;
> + ts->tv_sec++;
> + }
> +}
> +
> +static inline void timespec_add_ns(struct timespec *a, nsec_t ns)
> +{
> + while(unlikely(ns >= NSEC_PER_SEC)) {
> + ns -= NSEC_PER_SEC;
> + a->tv_sec++;
> + }
> + a->tv_nsec += ns;
> + normalize_timespec(a);
> +}
> +
> #endif /* __KERNEL__ */
>

are you sure you want this one inlined? that's 2 while loops already....
(and afaics the ns argument isn't a constant really so the first one
doesn't optimize out)


> +/**
> + * __get_nsec_offset - Returns nanoseconds since last call to periodic_hook
> + *
> + * private function, must hold system_time_lock lock when being
> + * called. Returns the number of nanoseconds since the
> + * last call to timeofday_periodic_hook() (adjusted by NTP scaling)
> + */
> +static inline nsec_t __get_nsec_offset(void)
> +{
> + cycle_t cycle_now, cycle_delta;
> + nsec_t ns_offset;
> +
> + /* read clocksource: */
> + cycle_now = read_clocksource(clock);
> +
> + /* calculate the delta since the last timeofday_periodic_hook: */
> + cycle_delta = (cycle_now - cycle_last) & clock->mask;
> +
> + /* convert to nanoseconds: */
> + ns_offset = cyc2ns(clock, ntp_adj, cycle_delta);
> +
> + /*
> + * special case for jiffies tick/offset based systems,
> + * add arch-specific offset:
> + */
> + ns_offset += arch_getoffset();
> +
> + return ns_offset;
> +}

likewise here..

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