aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorDavid P. Reed <dpreed@reed.com>2007-11-14 17:49:21 -0500
committerThomas Gleixner <tglx@apollo.(none)>2007-11-17 10:27:01 -0500
commitfa6a1a554b50cbb7763f6907e6fef927ead480d9 (patch)
tree9af94b945a5f10eaf2670ac14595db057d98054c /kernel
parentd0974b11e0741034fc5d22838b9cb85402a280d6 (diff)
ntp: fix typo that makes sync_cmos_clock erratic
Fix a typo in ntp.c that has caused updating of the persistent (RTC) clock when synced to NTP to behave erratically. When debugging a freeze that arises on my AMD64 machines when I run the ntpd service, I added a number of printk's to monitor the sync_cmos_clock procedure. I discovered that it was not syncing to cmos RTC every 11 minutes as documented, but instead would keep trying every second for hours at a time. The reason turned out to be a typo in sync_cmos_clock, where it attempts to ensure that update_persistent_clock is called very close to 500 msec. after a 1 second boundary (required by the PC RTC's spec). That typo referred to "xtime" in one spot, rather than "now", which is derived from "xtime" but not equal to it. This makes the test erratic, creating a "coin-flip" that decides when update_persistent_clock is called - when it is called, which is rarely, it may be at any time during the one second period, rather than close to 500 msec, so the value written is needlessly incorrect, too. Signed-off-by: David P. Reed Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/ntp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index de6a2d6b3ebb..14a2ecf2b318 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -205,7 +205,7 @@ static void sync_cmos_clock(unsigned long dummy)
205 return; 205 return;
206 206
207 getnstimeofday(&now); 207 getnstimeofday(&now);
208 if (abs(xtime.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) 208 if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2)
209 fail = update_persistent_clock(now); 209 fail = update_persistent_clock(now);
210 210
211 next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec; 211 next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec;