Skip to contentSkip to conversation

set_rtc_mmss: can't update from 0 to 59

DISCUSSION [email protected] 5 participants 8 messages Dec 17, 2000 – Dec 21, 2000

lore
Share & tools
lore
#0 lore raw

What architecture?
What kernel version?
Are you in fact running xntpd?

Quoted 2 lines

According to the notes in the code, this should work if my RTC is less than 15 minutes off... which I can guarantee it is.

Well, since you looked at the source:
For some randomly chosen kernel version and architecture it does

        if (abs(real_minutes - cmos_minutes) < 30) {
		update_cmos()
	} else {
		printk("set_rtc_mmss: can't update from %d to %d\n",
		       cmos_minutes, real_minutes);
	}

so if your cmos time is 0.001 sec ahead of your system time then around the hour you'll see
set_rtc_mmss: can't update from 0 to 59

Of course, messing with the cmos clock at all was a rather bad idea, but that is a different discussion.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 1 line · On Sun, Dec 17, 2000 at 09:54:18PM +0100, [email protected] wrote:

What architecture?

i386

Quoted 1 line

What kernel version?

2.4.0-test13-pre2, but this has been happening for a while.

Quoted 1 line

Are you in fact running xntpd?

Yes.

Quoted 13 lines
Quoted 2 lines

According to the notes in the code, this should work if my RTC is less than 15 minutes off... which I can guarantee it is.

Well, since you looked at the source:
For some randomly chosen kernel version and architecture it does

        if (abs(real_minutes - cmos_minutes) < 30) {
		update_cmos()
	} else {
		printk("set_rtc_mmss: can't update from %d to %d\n",
		       cmos_minutes, real_minutes);
	}
Quoted 3 lines

so if your cmos time is 0.001 sec ahead of your system time then around the hour you'll see
set_rtc_mmss: can't update from 0 to 59

Ahh... I think I see. While the math says "if the diference between the real time and the cmos time is less than 30 min", it doesn't recognize that the time difference between 2:59 and 3:00 is only 1 min.

Hrm.. the logic to get this right is always the type of thing that gets me... that's why I usually calculate things the UNIX way -- seconds since an epoch.

Quoted 2 lines

Of course, messing with the cmos clock at all was a rather bad idea, but that is a different discussion.

True enough... but, the question is, how do we fix this? Make the logic more buff? Or change the algorithm to use something like minutes since the epoch?

Matt

Signature · 6 lines
Matthew Dharm                              Home: [email protected] 
Maintainer, Linux USB Mass Storage Driver

We can customize our colonels.
					-- Tux
User Friendly, 12/1/1998
#2 lore raw
Quoted 3 lines · Matthew Dharm

Ahh... I think I see. While the math says "if the diference between the real time and the cmos time is less than 30 min", it doesn't recognize that the time difference between 2:59 and 3:00 is only 1 min.

Which is intentional.

Quoted 1 line

True enough... but, the question is, how do we fix this?

Why do you think it needs fixing?

Think about what happens when the current time according to the CMOS is 2:59:00 and Linux thinks its 3:01:20. We only write the minutes and seconds, so if we did write, the CMOS clock then becomes 2:01:20. Oops, we just lost an hour. Next time you reboot, you'll find the time out by an hour or more depending on how many corrections of this type have been done.

So, why don't we update the hours and be done with it? We would have to play the same game with the days of the month vs hours. Also, we don't know if the CMOS clock is programmed for UTC time or not (the kernel's idea of time is UTC. Your CMOS may be programmed for EST for instance).
_____

  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [email protected]      --- ---
  | | | | http://www.arm.linux.org.uk/personal/aboutme.html   /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
Quoted 18 lines · Russell King
Quoted 3 lines · Matthew Dharm

Ahh... I think I see. While the math says "if the diference between the real time and the cmos time is less than 30 min", it doesn't recognize that the time difference between 2:59 and 3:00 is only 1 min.

Which is intentional.

Quoted 1 line

True enough... but, the question is, how do we fix this?

Why do you think it needs fixing?

Think about what happens when the current time according to the CMOS is 2:59:00 and Linux thinks its 3:01:20. We only write the minutes and seconds, so if we did write, the CMOS clock then becomes 2:01:20. Oops, we just lost an hour. Next time you reboot, you'll find the time out by an hour or more depending on how many corrections of this type have been done.

Quoted 4 lines

So, why don't we update the hours and be done with it? We would have to play the same game with the days of the month vs hours. Also, we don't know if the CMOS clock is programmed for UTC time or not (the kernel's idea of time is UTC. Your CMOS may be programmed for EST for instance).

Sounds like its still broken then - there are time zones which are not even multiples of 60 minutes.

Signature · 6 lines
 "Love the dolphins," she advised him. "Write by W.A.S.T.E.."

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#4 lore raw
Quoted 8 lines · Oliver Xymoron
Quoted 4 lines · Russell King

So, why don't we update the hours and be done with it? We would have to play the same game with the days of the month vs hours. Also, we don't know if the CMOS clock is programmed for UTC time or not (the kernel's idea of time is UTC. Your CMOS may be programmed for EST for instance).

Sounds like its still broken then - there are time zones which are not even multiples of 60 minutes.

Correct; please examine the code and you will find the answer to this. Specifically, look at the lines around the following comment:

	/* correct for half hour time zone */
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [email protected]      --- ---
  | | | | http://www.arm.linux.org.uk/personal/aboutme.html   /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#5 lore raw
Quoted 7 lines · Russell King
Quoted 6 lines · Oliver Xymoron
Quoted 4 lines · Russell King

So, why don't we update the hours and be done with it? We would have to play the same game with the days of the month vs hours. Also, we don't know if the CMOS clock is programmed for UTC time or not (the kernel's idea of time is UTC. Your CMOS may be programmed for EST for instance).

Quoted 7 lines
Quoted 2 lines

Sounds like its still broken then - there are time zones which are not even multiples of 60 minutes.

Correct; please examine the code and you will find the answer to this. Specifically, look at the lines around the following comment:

	/* correct for half hour time zone */

Uhh.. Kathmandu? Chatham Island? +5:45 and +13:45 (DST) respectively.

At any rate, the printk should go - do_timer_interrupt already expects the "bug" its reporting.

Signature · 6 lines
 "Love the dolphins," she advised him. "Write by W.A.S.T.E.."

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#6 lore raw
In reply to [email protected]
Quoted 9 lines · Matthew Dharm
Quoted 2 lines · On Sun, Dec 17, 2000 at 09:54:18PM +0100, [email protected] wrote:

Of course, messing with the cmos clock at all was a rather bad idea, but that is a different discussion.

True enough... but, the question is, how do we fix this? Make the logic more buff? Or change the algorithm to use something like minutes since the epoch?

Actually I agree 100% with Andries -- having the kernel write back its time into the CMOS RTC every 11 minutes just because NTP is active seems like a random heuristic that probably "seemed like a good idea at the time". (Probably made more sense back when there were no other users of the RTC.)

It smells like policy in the kernel to me. What if a user wants to run NTP but wants the CMOS RTC time as an independent clock to do something else (possibly with the option of having a meaningful /etc/adjtime too) ?

Can't the people who want the current behaviour simply have a crontab that runs (hw)clock -[u]w from util-linux at whatever interval they want? Then set_rtc_mmss magically goes away, the kernel doesn't need to know UTC vs. local, and the timer interrupt gets smaller - a Good Thing(tm).

I'd delete set_rtc_mmss entirely, but I just #ifdef'd it out in case I'm overlooking something...

Paul.

arch/i386/kernel/time.c renamed from arch/i386/kernel/time.c~ +15 -0
@@ -28,6 +28,9 @@
  * 1998-12-24 Copyright (C) 1998  Andrea Arcangeli
  *	Fixed a xtime SMP race (we need the xtime_lock rw spinlock to
  *	serialize accesses to xtime/lost_ticks).
+ * 2000-12-20	Paul Gortmaker
+ *	Don't mess with the CMOS clock just because NTP is used.  This
+ *	gets rid of annoying "set_rtc_mmss: can't update ..." messages.
  */
 
 #include <linux/errno.h>
@@ -304,7 +307,16 @@
 	write_unlock_irq(&xtime_lock);
 }
 
+#ifdef INVALIDATE_ADJTIME
 /*
+ * NOTE: This is NOT an externally exported interface for setting 
+ * the time stored in the RTC.  It is ONLY used internally to store
+ * the kernel time back into the RTC if the kernel time is externally
+ * synchronized.  (Yes, this smells like policy in the kernel...)
+ * If you enable this then your /etc/adjtime value(s) are no longer 
+ * valid. Conversely, non-zero /etc/adjtime values can result in this
+ * spewing the "set_rtc_mmss: cant update from N to M" messages.
+ *
  * In order to set the CMOS clock precisely, set_rtc_mmss has to be
  * called 500 ms after the second nowtime has started, because when
  * nowtime is written into the registers of the CMOS clock, it will
@@ -374,6 +386,7 @@
 
 /* last time the cmos clock got updated */
 static long last_rtc_update;
+#endif
 
 int timer_ack;
 
@@ -417,6 +430,7 @@
 		smp_local_timer_interrupt(regs);
 #endif
 
+#ifdef INVALIDATE_ADJTIME
 	/*
 	 * If we have an externally synchronized Linux clock, then update
 	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
@@ -431,6 +445,7 @@
 		else
 			last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
 	}
+#endif
 	    
 #ifdef CONFIG_MCA
 	if( MCA_bus ) {

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#7 lore raw
Quoted 3 lines · Paul Gortmaker

It smells like policy in the kernel to me. What if a user wants to run NTP but wants the CMOS RTC time as an independent clock to do something else (possibly with the option of having a meaningful /etc/adjtime too) ?

NTP and adjtime are synomonous - NTP uses the adjtimex call to adjust the local clock. Therefore, when running NTP, leave adjtime well alone (unless you want to break NTP). You either use NTP or adjtime, not both.

Quoted 2 lines

Can't the people who want the current behaviour simply have a crontab that runs (hw)clock -[u]w from util-linux at whatever interval they want?

And how do you handle the situation where NTP hasn't synchronised, and therefore the local hardware clock should not be updated? Sometimes the hardware clock is higher precision than the kernels idea of time (ok, not in cheap PCs).
_____

  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [email protected]      --- ---
  | | | | http://www.arm.linux.org.uk/personal/aboutme.html   /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/