Skip to content

Commit

Permalink
ntp: Clamp PLL update interval
Browse files Browse the repository at this point in the history
Clamp update interval to reduce PLL gain with low sampling rate (e.g.
intermittent network connection) to avoid instability.

The clamp roughly corresponds to the loop time constant, it's 8 * poll
interval for SHIFT_PLL 2 and 32 * poll interval for SHIFT_PLL 4. This
gives good results without affecting the gain in normal conditions where
ntpd skips only up to seven consecutive samples.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Acked-by: john stultz <johnstul@us.ibm.com>
LKML-Reference: <1283870626-9472-1-git-send-email-mlichvar@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Miroslav Lichvar authored and Thomas Gleixner committed Sep 9, 2010
1 parent d56557a commit 8af3c15
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions kernel/time/ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,18 @@ static void ntp_update_offset(long offset)
time_reftime = get_seconds();

offset64 = offset;
freq_adj = (offset64 * secs) <<
(NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant));
freq_adj = ntp_update_offset_fll(offset64, secs);

freq_adj += ntp_update_offset_fll(offset64, secs);
/*
* Clamp update interval to reduce PLL gain with low
* sampling rate (e.g. intermittent network connection)
* to avoid instability.
*/
if (unlikely(secs > 1 << (SHIFT_PLL + 1 + time_constant)))
secs = 1 << (SHIFT_PLL + 1 + time_constant);

freq_adj += (offset64 * secs) <<
(NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant));

freq_adj = min(freq_adj + time_freq, MAXFREQ_SCALED);

Expand Down

0 comments on commit 8af3c15

Please sign in to comment.