Re: [RFC][PATCH] new timeofday core subsystem (v. A3)

From: Christoph Lameter
Date: Tue Mar 15 2005 - 01:14:13 EST


On Fri, 11 Mar 2005, john stultz wrote:

> +/* cyc2ns():
> + * Uses the timesource and ntp ajdustment interval to
> + * convert cycle_ts to nanoseconds.
> + * If rem is not null, it stores the remainder of the
> + * calculation there.
> + *
> + */

This function is called in critical paths and it would be very important
to optimize it further.

> +static inline nsec_t cyc2ns(struct timesource_t* ts, int ntp_adj, cycle_t cycles, cycle_t* rem)
> +{
> + u64 ret;
> + ret = (u64)cycles;
> + ret *= (ts->mult + ntp_adj);

This only changes when nt_adj changes. Maybe maintain the sum separately?

> + if (unlikely(rem)) {
> + /* XXX clean this up later!
> + * buf for now relax, we only calc
> + * remainders at interrupt time
> + */
> + u64 remainder = ret & ((1 << ts->shift) -1);
> + do_div(remainder, ts->mult);
> + *rem = remainder;

IA64 does not do remainder processing (maybe I just do not understand
this...) but this seems to be not necessay if one uses 64 bit values that
are properly shifted?

> + }
> + ret >>= ts->shift;
> + return (nsec_t)ret;
> +}

The whole function could simply be:

#define cyc2ns(cycles, ts) (cycles*ts->current_factor) >> ts->shift
-
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/