Commit 8af3c153baf95374eff20a37f00c59a295b52756

Authored by Miroslav Lichvar
Committed by Thomas Gleixner
1 parent d56557af19

ntp: Clamp PLL update interval

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>

Showing 1 changed file with 11 additions and 3 deletions Side-by-side Diff

... ... @@ -149,10 +149,18 @@
149 149 time_reftime = get_seconds();
150 150  
151 151 offset64 = offset;
152   - freq_adj = (offset64 * secs) <<
153   - (NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant));
  152 + freq_adj = ntp_update_offset_fll(offset64, secs);
154 153  
155   - freq_adj += ntp_update_offset_fll(offset64, secs);
  154 + /*
  155 + * Clamp update interval to reduce PLL gain with low
  156 + * sampling rate (e.g. intermittent network connection)
  157 + * to avoid instability.
  158 + */
  159 + if (unlikely(secs > 1 << (SHIFT_PLL + 1 + time_constant)))
  160 + secs = 1 << (SHIFT_PLL + 1 + time_constant);
  161 +
  162 + freq_adj += (offset64 * secs) <<
  163 + (NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant));
156 164  
157 165 freq_adj = min(freq_adj + time_freq, MAXFREQ_SCALED);
158 166