diff options
author | john stultz <johnstul@us.ibm.com> | 2009-05-06 05:43:57 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-06 05:44:02 -0400 |
commit | 22cfbbfd9f67b67fe073010f51cb71d3632387d5 (patch) | |
tree | 571aff3fc26da4ae5853fb3cf4d4b924c2893c7b /include/linux/timex.h | |
parent | 413f81eba35d6ede9289b0c8a920c013a84fac71 (diff) |
ntp: adjust SHIFT_PLL to improve NTP convergence
The conversion to the ntpv4 reference model
f19923937321244e7dc334767eb4b67e0e3d5c74 ("ntp: convert to the NTP4
reference model") in 2.6.19 added nanosecond resolution the adjtimex
interface, but also changed the "stiffness" of the frequency adjustments,
causing NTP convergence time to greatly increase.
SHIFT_PLL, which reduces the stiffness of the freq adjustments, was
designed to be inversely linked to HZ, and the reference value of 4 was
designed for Unix systems using HZ=100. However Linux's clock steering
code mostly independent of HZ.
So this patch reduces the SHIFT_PLL value from 4 to 2, which causes NTPd
behavior to match kernels prior to 2.6.19, greatly reducing convergence
times, and improving close synchronization through environmental thermal
changes.
The patch also changes some l's to L's in nearby code to avoid misreading
50l as 501.
[ Impact: tweak NTP algorithm for faster convergence ]
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: zippel@linux-m68k.org
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <200905051956.n45JuVo9025575@imap1.linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/timex.h')
-rw-r--r-- | include/linux/timex.h | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/include/linux/timex.h b/include/linux/timex.h index aa3475fcff64..0daf9611ef4f 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h | |||
@@ -170,17 +170,37 @@ struct timex { | |||
170 | #include <asm/timex.h> | 170 | #include <asm/timex.h> |
171 | 171 | ||
172 | /* | 172 | /* |
173 | * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen | 173 | * SHIFT_PLL is used as a dampening factor to define how much we |
174 | * for a slightly underdamped convergence characteristic. SHIFT_KH | 174 | * adjust the frequency correction for a given offset in PLL mode. |
175 | * establishes the damping of the FLL and is chosen by wisdom and black | 175 | * It also used in dampening the offset correction, to define how |
176 | * art. | 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 | 182 | * In David Mills' nanokenrel reference implmentation SHIFT_PLL is 4. |
179 | * SHIFT_KG and SHIFT_KF values given and a time constant range from | 183 | * However this seems to increase convergence time much too long. |
180 | * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours, | 184 | * |
181 | * respectively. | 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' nanokenrel reference implmentation SHIFT_PLL 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 | #define SHIFT_FLL 2 /* FLL frequency factor (shift) */ | 204 | #define SHIFT_FLL 2 /* FLL frequency factor (shift) */ |
185 | #define MAXTC 10 /* maximum time constant (shift) */ | 205 | #define MAXTC 10 /* maximum time constant (shift) */ |
186 | 206 | ||
@@ -192,10 +212,10 @@ struct timex { | |||
192 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ | 212 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ |
193 | #define PPM_SCALE ((s64)NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) | 213 | #define PPM_SCALE ((s64)NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) |
194 | #define PPM_SCALE_INV_SHIFT 19 | 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 | PPM_SCALE + 1) | 216 | PPM_SCALE + 1) |
197 | 217 | ||
198 | #define MAXPHASE 500000000l /* max phase error (ns) */ | 218 | #define MAXPHASE 500000000L /* max phase error (ns) */ |
199 | #define MAXFREQ 500000 /* max frequency error (ns/s) */ | 219 | #define MAXFREQ 500000 /* max frequency error (ns/s) */ |
200 | #define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT) | 220 | #define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT) |
201 | #define MINSEC 256 /* min interval between updates (s) */ | 221 | #define MINSEC 256 /* min interval between updates (s) */ |