lkml.org 
[lkml]   [2008]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 10/11] time sync: generic infrastructure to map between time stamps generated by a clock source and system time

These patcehs add a lot of quite large inlined functions.

On Wed, 19 Nov 2008 13:08:47 +0100
Patrick Ohly <patrick.ohly@intel.com> wrote:

> +static inline void clocksync_update(struct clocksync *sync,
> + u64 hwtstamp)
> +{
> + s64 offset;
> + u64 average_time;
> +
> + if (hwtstamp &&
> + (s64)(hwtstamp - sync->last_update) < NSEC_PER_SEC)
> + return;
> +
> + if (!clocksync_offset(sync, &offset, &average_time))
> + return;
> +
> + printk(KERN_DEBUG
> + "average offset: %lld\n", offset);
> +
> + if (!sync->last_update) {
> + sync->last_update = average_time;
> + sync->offset = offset;
> + sync->skew = 0;
> + } else {
> + s64 delta_nsec = average_time - sync->last_update;
> +
> + /* avoid division by negative or small deltas */
> + if (delta_nsec >= 10000) {
> + s64 delta_offset_nsec = offset - sync->offset;
> + s64 skew = delta_offset_nsec *
> + CLOCKSYNC_SKEW_RESOLUTION /
> + delta_nsec;
> +
> + /**
> + * Calculate new overall skew as 4/16 the
> + * old value and 12/16 the new one. This is
> + * a rather arbitrary tradeoff between
> + * only using the latest measurement (0/16 and
> + * 16/16) and even more weight on past measurements.
> + */
> +#define CLOCKSYNC_NEW_SKEW_PER_16 12
> + sync->skew =
> + ((16 - CLOCKSYNC_NEW_SKEW_PER_16) * sync->skew +
> + CLOCKSYNC_NEW_SKEW_PER_16 * skew) /
> + 16;
> + sync->last_update = average_time;
> + sync->offset = offset;
> + }
> + }
> +}

This one is a champ.

The token '/**' is used exclusively to introduce kerneldoc-formatted
comments. Please check the patches for comments which are incorrectly
thus-tagged.
Please cc linux-api@vger.kernel.org on patches which affect the
kernel's userspace interfaces.



\
 
 \ /
  Last update: 2008-11-20 02:17    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site