• Thomas Gleixner's avatar
    x86: tsc prevent time going backwards · d8bb6f4c
    Thomas Gleixner authored
    We already catch most of the TSC problems by sanity checks, but there
    is a subtle bug which has been in the code forever. This can cause
    time jumps in the range of hours.
    
    This was reported in:
         http://lkml.org/lkml/2007/8/23/96
    and
         http://lkml.org/lkml/2008/3/31/23
    
    I was able to reproduce the problem with a gettimeofday loop test on a
    dual core and a quad core machine which both have sychronized
    TSCs. The TSCs seems not to be perfectly in sync though, but the
    kernel is not able to detect the slight delta in the sync check. Still
    there exists an extremly small window where this delta can be observed
    with a real big time jump. So far I was only able to reproduce this
    with the vsyscall gettimeofday implementation, but in theory this
    might be observable with the syscall based version as well.
    
    CPU 0 updates the clock source variables under xtime/vyscall lock and
    CPU1, where the TSC is slighty behind CPU0, is reading the time right
    after the seqlock was unlocked...
    d8bb6f4c
timekeeping.c 13.4 KB