Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get_cmos_time() takes up to a second on boot

34 views
Skip to first unread message

Tim Bird

unread,
May 7, 2004, 8:40:09 PM5/7/04
to
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 in
mach_get_cmos_time() in
include/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
=============================

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linus Torvalds

unread,
May 7, 2004, 10:20:20 PM5/7/04
to

On Fri, 7 May 2004, Tim Bird wrote:
>
> 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?

> 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).

> 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

Matthias Urlichs

unread,
May 10, 2004, 2:20:05 AM5/10/04
to
Hi, Linus Torvalds wrote:

> 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.

--
Matthias Urlichs

Gabriel Paubert

unread,
May 10, 2004, 7:10:10 AM5/10/04
to
On Fri, May 07, 2004 at 07:15:53PM -0700, Linus Torvalds wrote:
>
>
> On Fri, 7 May 2004, Tim Bird wrote:
> >
> > 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).

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).

>
> Does anybody remember better?
>
> > 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.

>
> > 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

Andries Brouwer

unread,
May 10, 2004, 8:00:19 AM5/10/04
to
On Fri, May 07, 2004 at 07:15:53PM -0700, Linus Torvalds wrote:

>> 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".

On Mon, May 10, 2004 at 12:52:30PM +0200, Gabriel Paubert wrote:

> 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?]

0 new messages