@@ -170,17 +170,37 @@ struct timex {
170
170
#include <asm/timex.h>
171
171
172
172
/*
173
- * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
174
- * for a slightly underdamped convergence characteristic. SHIFT_KH
175
- * establishes the damping of the FLL and is chosen by wisdom and black
176
- * art.
173
+ * SHIFT_PLL is used as a dampening factor to define how much we
174
+ * adjust the frequency correction for a given offset in PLL mode.
175
+ * It also used in dampening the offset correction, to define how
176
+ * much of the current value in time_offset we correct for each
177
+ * second. Changing this value changes the stiffness of the ntp
178
+ * adjustment code. A lower value makes it more flexible, reducing
179
+ * NTP convergence time. A higher value makes it stiffer, increasing
180
+ * convergence time, but making the clock more stable.
177
181
*
178
- * MAXTC establishes the maximum time constant of the PLL. With the
179
- * SHIFT_KG and SHIFT_KF values given and a time constant range from
180
- * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
181
- * respectively.
182
+ * In David Mills' nanokernel reference implementation SHIFT_PLL is 4.
183
+ * However this seems to increase convergence time much too long.
184
+ *
185
+ * https://lists.ntp.org/pipermail/hackers/2008-January/003487.html
186
+ *
187
+ * In the above mailing list discussion, it seems the value of 4
188
+ * was appropriate for other Unix systems with HZ=100, and that
189
+ * SHIFT_PLL should be decreased as HZ increases. However, Linux's
190
+ * clock steering implementation is HZ independent.
191
+ *
192
+ * Through experimentation, a SHIFT_PLL value of 2 was found to allow
193
+ * for fast convergence (very similar to the NTPv3 code used prior to
194
+ * v2.6.19), with good clock stability.
195
+ *
196
+ *
197
+ * SHIFT_FLL is used as a dampening factor to define how much we
198
+ * adjust the frequency correction for a given offset in FLL mode.
199
+ * In David Mills' nanokernel reference implementation SHIFT_FLL is 2.
200
+ *
201
+ * MAXTC establishes the maximum time constant of the PLL.
182
202
*/
183
- #define SHIFT_PLL 4 /* PLL frequency factor (shift) */
203
+ #define SHIFT_PLL 2 /* PLL frequency factor (shift) */
184
204
#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
185
205
#define MAXTC 10 /* maximum time constant (shift) */
186
206
@@ -192,10 +212,10 @@ struct timex {
192
212
#define SHIFT_USEC 16 /* frequency offset scale (shift) */
193
213
#define PPM_SCALE ((s64)NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
194
214
#define PPM_SCALE_INV_SHIFT 19
195
- #define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
215
+ #define PPM_SCALE_INV ((1LL << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
196
216
PPM_SCALE + 1)
197
217
198
- #define MAXPHASE 500000000l /* max phase error (ns) */
218
+ #define MAXPHASE 500000000L /* max phase error (ns) */
199
219
#define MAXFREQ 500000 /* max frequency error (ns/s) */
200
220
#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
201
221
#define MINSEC 256 /* min interval between updates (s) */
0 commit comments