get_cmos_time() takes up to a second on boot
In Linux 2.4.20, the routine get_cmos_time() in arch/i386/kernel/time.c takes up to a second to run during a boot on an x86 desktop.
It looks like this is because of the first 'for' loop where it synchronizes with the edge of the RTC clock (and where the comment reads "may take up to 1 second...")
In Linux 2.6.5, this same code appears inmach_get_cmos_time() ininclude/asm-i386/mach-default/mach_time.c
(but I haven't measured it on 2.6.5 yet).
What is the downside of disabling this
synchronization with the clock edge?
1 second of variability is unnacceptable
when you're requirement is to boot in
.5 seconds. :)
Would it be bad to disable this synchronization completely? How about just during boot?
=============================
Tim Bird
Chair, Bootup Time Working Group, CE Linux Forum Senior Staff Engineer, Sony Electronics
=============================
Quoted 3 lines · Tim Bird
What is the downside of disabling this synchronization with the clock edge?
It might not matter any more, but if I remember correctly, the real problem was that we used to always write back the time to the CMOS clock too, and then booting a few times and consistently getting the time wrong the same way made the clock drift quite noticeably.
These days, I think we do the write-back only if we use an external clock (NTP), so we probably _could_ just remove the synchronization at read-time (removing it at write-time doesn't sound like a good idea).
Does anybody remember better?
Quoted 3 lines
1 second of variability is unnacceptable when you're requirement is to boot in
.5 seconds. :)
Heh. And yes, it could be handled other ways (you could check the cmos time in the timer interrupt during boot, and correct it there rather than busy-waiting).
Quoted 2 lines
Would it be bad to disable this synchronization completely? How about just during boot?
I don't think we should necessarily disable the synchronization, but we could certainly make it optional for cases that don't care about it. We might even make the default be "don't care about the read synchronization".
Linus
Quoted 5 lines · Linus Torvalds
These days, I think we do the write-back only if we use an external clock (NTP), so we probably _could_ just remove the synchronization at read-time (removing it at write-time doesn't sound like a good idea).
Does anybody remember better?
No. ;-) Do it.
Signature · 1 line
Matthias Urlichs
Quoted 7 lines · Linus Torvalds
Quoted 3 lines · Tim Bird
What is the downside of disabling this synchronization with the clock edge?
Quoted 8 lines
It might not matter any more, but if I remember correctly, the real problem was that we used to always write back the time to the CMOS clock too, and then booting a few times and consistently getting the time wrong the same way made the clock drift quite noticeably.
These days, I think we do the write-back only if we use an external clock (NTP), so we probably _could_ just remove the synchronization at read-time (removing it at write-time doesn't sound like a good idea).
Indeed, it is necessary at write-time. Note that from my experience most RTC are not very accurate, as if the first 10 to 12 stages of the 32768 Hz divider were unaffected by the writes: with 10 msec jiffies I often see the time jump by a few tens of milliseconds at boot from ntpdate (I have reference clocks on the same LAN, with errors only exceptionally above 1 millisecond and the RTC is only written from the kernel every 11 minutes, _never_ from the shutdown scripts).
Quoted 9 lines
Does anybody remember better?
Quoted 3 lines
1 second of variability is unnacceptable when you're requirement is to boot in
.5 seconds. :)Heh. And yes, it could be handled other ways (you could check the cmos busy-waiting).
Fine. But boot time below one second are fundamentally incompatible with avoiding/minimzing time jumps after user mode has started, which is what worries me. Well, unless you have better RTC with subsecond fields, that is.
Quoted 8 lines
Quoted 3 lines
Would it be bad to disable this synchronization completely? How about just during boot?
I don't think we should necessarily disable the synchronization, but we could certainly make it optional for cases that don't care about it. We might even make the default be "don't care about the read synchronization".
I'm for one againt dropping the synchronization and even making the default not to synchronize, I'd rather see this as an option under the embedded subset for the people who really want fast boot time. Anybody not booting from ROM/Flash/MTD (the overwhelming majority AFAICS) won't ever notice the time lost in synchronizing with the RTC edge, especially if it's not done by busy waiting.
Regards,
Gabriel
Quoted 8 lines · Linus Torvalds
Quoted 8 lines
These days, I think we do the write-back only if we use an external clock (NTP), so we probably _could_ just remove the synchronization at read-time (removing it at write-time doesn't sound like a good idea).
I don't think we should necessarily disable the synchronization, but we could certainly make it optional for cases that don't care about it. We might even make the default be "don't care about the read synchronization".
Quoted 3 lines · Gabriel Paubert
I'm for one against dropping the synchronization and even making the default not to synchronize, I'd rather see this as an option under the embedded subset for the people who really want fast boot time.
There is hwclock that will read or write the CMOS clock, and it synchronizes.
So if one wants to synchronize with the CMOS clock (rather than, say, with an external clock), and wants the better-than-1-sec accuracy, then that can be done in a boot script.
Andries
[I think everybody likes fast boot time.
Ah - 30 years ago my system booted in the fraction of a second needed to print the command prompt.
Why have computers become so slow?]