Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753704AbYKTBPI (ORCPT ); Wed, 19 Nov 2008 20:15:08 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753310AbYKTBOu (ORCPT ); Wed, 19 Nov 2008 20:14:50 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:33383 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752524AbYKTBOt (ORCPT ); Wed, 19 Nov 2008 20:14:49 -0500 Date: Wed, 19 Nov 2008 17:14:45 -0800 From: Andrew Morton To: Patrick Ohly Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, davem@davemloft.net, patrick.ohly@intel.com Subject: Re: [RFC PATCH 10/11] time sync: generic infrastructure to map between time stamps generated by a clock source and system time Message-Id: <20081119171445.bd02498e.akpm@linux-foundation.org> In-Reply-To: <1227096528-24150-11-git-send-email-patrick.ohly@intel.com> References: <1227096528-24150-1-git-send-email-patrick.ohly@intel.com> <1227096528-24150-2-git-send-email-patrick.ohly@intel.com> <1227096528-24150-3-git-send-email-patrick.ohly@intel.com> <1227096528-24150-4-git-send-email-patrick.ohly@intel.com> <1227096528-24150-5-git-send-email-patrick.ohly@intel.com> <1227096528-24150-6-git-send-email-patrick.ohly@intel.com> <1227096528-24150-7-git-send-email-patrick.ohly@intel.com> <1227096528-24150-8-git-send-email-patrick.ohly@intel.com> <1227096528-24150-9-git-send-email-patrick.ohly@intel.com> <1227096528-24150-10-git-send-email-patrick.ohly@intel.com> <1227096528-24150-11-git-send-email-patrick.ohly@intel.com> X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1980 Lines: 68 These patcehs add a lot of quite large inlined functions. On Wed, 19 Nov 2008 13:08:47 +0100 Patrick Ohly 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/