Re: drift in ntpd may not catch up on bad clock and keep slipping.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Daniel Ouellet <daniel@...>
Cc: misc@openbsd.org <misc@...>
Date: Monday, December 10, 2007 - 5:44 pm

On Mon, Dec 10, 2007 at 04:07:17PM -0500, Daniel Ouellet wrote:

> Hi,

Some archs use timecounter code now for the clock. That code has a lot
of benefits, but the range of clock drifts that can be compensated for
is not very big. I have an experimental diff here that might solve
your case. See below.

> One example of sampling, where th gap keep getting bigger:

I would really have to look into the code to see if it's feasible to
start adjusting frequency when not synced. Currently I do not think it
will work without some rewriting. I am also worried the complexity of
the code would increase, or some oscillating effect would be
introduced in some cases.

>

Yes, you can create a drift file yourself and (re)start ntpd. For that
to work you'll need a reasnable estimate of the dirft.

So to summarize, you can do three things:

1. Test the diff below
2. Hack the ntpd code to start using adjfreq without being synced (not recommended)
3. Estimate the drift yousrelf and create a ntpd.drift file.

I would start with 1.

-Otto

Index: kern_tc.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_tc.c,v
retrieving revision 1.9
diff -u -p -r1.9 kern_tc.c
--- kern_tc.c 9 May 2007 17:42:19 -0000 1.9
+++ kern_tc.c 12 Nov 2007 20:07:17 -0000
@@ -567,11 +567,11 @@ ntp_update_second(int64_t *adjust, time_
if (adjtimedelta.tv_sec > 0)
adj.tv_usec = 5000;
else if (adjtimedelta.tv_sec == 0)
- adj.tv_usec = MIN(500, adjtimedelta.tv_usec);
+ adj.tv_usec = MIN(5000, adjtimedelta.tv_usec);
else if (adjtimedelta.tv_sec < -1)
adj.tv_usec = -5000;
else if (adjtimedelta.tv_sec == -1)
- adj.tv_usec = MAX(-500, adjtimedelta.tv_usec - 1000000);
+ adj.tv_usec = MAX(-5000, adjtimedelta.tv_usec - 1000000);
timersub(&adjtimedelta, &adj, &adjtimedelta);
*adjust = ((int64_t)adj.tv_usec * 1000) << 32;
*adjust += timecounter->tc_freq_adj;

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: drift in ntpd may not catch up on bad clock and keep sli..., Otto Moerbeek, (Mon Dec 10, 5:44 pm)