Skip to content

Commit 9aaa630

Browse files
committed
Merge branch 'timers-for-linus-ntp' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-for-linus-ntp' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: ntp: fix comment typos ntp: adjust SHIFT_PLL to improve NTP convergence
2 parents 2ed0e21 + e13cf6e commit 9aaa630

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

include/linux/timex.h

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,37 @@ struct timex {
170170
#include <asm/timex.h>
171171

172172
/*
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.
177181
*
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.
182202
*/
183-
#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
203+
#define SHIFT_PLL 2 /* PLL frequency factor (shift) */
184204
#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
185205
#define MAXTC 10 /* maximum time constant (shift) */
186206

@@ -192,10 +212,10 @@ struct timex {
192212
#define SHIFT_USEC 16 /* frequency offset scale (shift) */
193213
#define PPM_SCALE ((s64)NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
194214
#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)) / \
196216
PPM_SCALE + 1)
197217

198-
#define MAXPHASE 500000000l /* max phase error (ns) */
218+
#define MAXPHASE 500000000L /* max phase error (ns) */
199219
#define MAXFREQ 500000 /* max frequency error (ns/s) */
200220
#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
201221
#define MINSEC 256 /* min interval between updates (s) */

0 commit comments

Comments
 (0)