ntp: correct inconsistent interval/tick_length usage

clocksource initialization and error accumulation. This corrects a 280ppm
drift seen on some systems using acpi_pm, and affects other clocksources as
well (likely to a lesser degree).

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by john stultz and committed by Thomas Gleixner e13a2e61 25f66630

+8 -5
+8 -1
include/linux/timex.h
··· 232 #else 233 #define NTP_INTERVAL_FREQ (HZ) 234 #endif 235 - #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) 236 237 /* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ 238 extern u64 current_tick_length(void);
··· 232 #else 233 #define NTP_INTERVAL_FREQ (HZ) 234 #endif 235 + 236 + #define CLOCK_TICK_OVERFLOW (LATCH * HZ - CLOCK_TICK_RATE) 237 + #define CLOCK_TICK_ADJUST (((s64)CLOCK_TICK_OVERFLOW * NSEC_PER_SEC) / \ 238 + (s64)CLOCK_TICK_RATE) 239 + 240 + /* Because using NSEC_PER_SEC would be too easy */ 241 + #define NTP_INTERVAL_LENGTH ((((s64)TICK_USEC * NSEC_PER_USEC * USER_HZ) + \ 242 + CLOCK_TICK_ADJUST) / NTP_INTERVAL_FREQ) 243 244 /* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ 245 extern u64 current_tick_length(void);
-4
kernel/time/ntp.c
··· 43 static long time_reftime; /* time at last adjustment (s) */ 44 long time_adjust; 45 46 - #define CLOCK_TICK_OVERFLOW (LATCH * HZ - CLOCK_TICK_RATE) 47 - #define CLOCK_TICK_ADJUST (((s64)CLOCK_TICK_OVERFLOW * NSEC_PER_SEC) / \ 48 - (s64)CLOCK_TICK_RATE) 49 - 50 static void ntp_update_frequency(void) 51 { 52 u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)
··· 43 static long time_reftime; /* time at last adjustment (s) */ 44 long time_adjust; 45 46 static void ntp_update_frequency(void) 47 { 48 u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)