Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

time: remove obsolete CLOCK_TICK_ADJUST

The first version of the ntp_interval/tick_length inconsistent usage patch was
recently merged as bbe4d18ac2e058c56adb0cd71f49d9ed3216a405

http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bbe4d18ac2e058c56adb0cd71f49d9ed3216a405

While the fix did greatly improve the situation, it was correctly pointed out
by Roman that it does have a small bug: If the users change clocksources after
the system has been running and NTP has made corrections, the correctoins made
against the old clocksource will be applied against the new clocksource,
causing error.

The second attempt, which corrects the issue in the NTP_INTERVAL_LENGTH
definition has also made it up-stream as commit
e13a2e61dd5152f5499d2003470acf9c838eab84

http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e13a2e61dd5152f5499d2003470acf9c838eab84

Roman has correctly pointed out that CLOCK_TICK_ADJUST is calculated
based on the PIT's frequency, and isn't really relevant to non-PIT
driven clocksources (that is, clocksources other then jiffies and pit).

This patch reverts both of those changes, and simply removes
CLOCK_TICK_ADJUST.

This does remove the granularity error correction for users of PIT and Jiffies
clocksource users, but the granularity error but for the majority of users, it
should be within the 500ppm range NTP can accommodate for.

For systems that have granularity errors greater then 500ppm, the
"ntp_tick_adj=" boot option can be used to compensate.

[johnstul@us.ibm.com: provided changelog]
[mattilinnanvuori@yahoo.com: maek ntp_tick_adj static]
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Acked-by: john stultz <johnstul@us.ibm.com>
Signed-off-by: Matti Linnanvuori <mattilinnanvuori@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: mingo@elte.hu
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Roman Zippel and committed by
Thomas Gleixner
10a398d0 a7901766

+13 -13
+1 -8
include/linux/timex.h
··· 232 232 #else 233 233 #define NTP_INTERVAL_FREQ (HZ) 234 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) 235 + #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) 243 236 244 237 /* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ 245 238 extern u64 current_tick_length(void);
+10 -1
kernel/time/ntp.c
··· 42 42 long time_freq; /* frequency offset (scaled ppm)*/ 43 43 static long time_reftime; /* time at last adjustment (s) */ 44 44 long time_adjust; 45 + static long ntp_tick_adj; 45 46 46 47 static void ntp_update_frequency(void) 47 48 { 48 49 u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) 49 50 << TICK_LENGTH_SHIFT; 50 - second_length += (s64)CLOCK_TICK_ADJUST << TICK_LENGTH_SHIFT; 51 + second_length += (s64)ntp_tick_adj << TICK_LENGTH_SHIFT; 51 52 second_length += (s64)time_freq << (TICK_LENGTH_SHIFT - SHIFT_NSEC); 52 53 53 54 tick_length_base = second_length; ··· 403 402 notify_cmos_timer(); 404 403 return(result); 405 404 } 405 + 406 + static int __init ntp_tick_adj_setup(char *str) 407 + { 408 + ntp_tick_adj = simple_strtol(str, NULL, 0); 409 + return 1; 410 + } 411 + 412 + __setup("ntp_tick_adj=", ntp_tick_adj_setup);
+2 -4
kernel/time/timekeeping.c
··· 187 187 188 188 clock->error = 0; 189 189 clock->xtime_nsec = 0; 190 - clocksource_calculate_interval(clock, 191 - (unsigned long)(current_tick_length()>>TICK_LENGTH_SHIFT)); 190 + clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH); 192 191 193 192 tick_clock_notify(); 194 193 ··· 244 245 ntp_clear(); 245 246 246 247 clock = clocksource_get_next(); 247 - clocksource_calculate_interval(clock, 248 - (unsigned long)(current_tick_length()>>TICK_LENGTH_SHIFT)); 248 + clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH); 249 249 clock->cycle_last = clocksource_read(clock); 250 250 251 251 xtime.tv_sec = sec;