timer: handle fast clocks
authorAlan Cox <alan@linux.intel.com>
Thu, 20 Sep 2018 00:54:55 +0000 (01:54 +0100)
committerAlan Cox <alan@linux.intel.com>
Thu, 20 Sep 2018 00:54:55 +0000 (01:54 +0100)
On a few systems the timer tick can run too fast (eg it's 0.512 of a second
not 0.5) and we can tick ahead of the RTC time. For robustness treat being
a second ahead of locked time as we do being on time - don't tick again so
we'll slide into time.

We shouldn't end up any further out because the big jumps are only when we
have interrupts off for stuff like floppy disk I/O. In that situation we
will always lose time.

Kernel/timer.c

index b0ad2ec..7811094 100644 (file)
@@ -112,10 +112,11 @@ void updatetod(void)
        slide = rtcnew - rtcsec;        /* Seconds elapsed */
        rtcsec = rtcnew;
        /*
-        *      FIXME: it would be nice if we see a backwards slide of 1 or 2
-        *      to stall the OS clock so we can use an rtc to track a not so
-        *      stable system clock.
+        *      We assume a small negative warp in seconds is telling us
+        *      that the clock is running too fast and we should stall.
         */
+       if (slide == -1)
+               return;
 addtod:
        if (slide < 0)
                slide += 60;            /* Seconds wrapped */