[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20081119171445.bd02498e.akpm@linux-foundation.org>
Date: Wed, 19 Nov 2008 17:14:45 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Patrick Ohly <patrick.ohly@...el.com>
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
davem@...emloft.net, patrick.ohly@...el.com
Subject: Re: [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@...el.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@...r.kernel.org on patches which affect the
kernel's userspace interfaces.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists