• Andrew Morton's avatar
    [PATCH] detect_lost_tick locking fixes · d9a4b6c5
    Andrew Morton authored
    From: john stultz <johnstul@us.ibm.com>
    
    This patch fixes a race in the timer_interrupt code caused by
    detect_lost_tick().  Since we're doing lost-tick compensation outside
    timer->mark_offset, time can pass between time-source reads which can cause
    gettimeofday inconsistencies.
    
    Additionally detect_lost_tick() was broken for the PIT case, since the whole
    point of detect_lost_tick() is to interpolate between two time sources to
    find inconsistencies.  Additionally this could cause xtime_lock seq_lock
    reader starvation which has been causing machine hangs for SMP boxes that use
    the PIT as a time source.
    
    This patch fixes the described race by removing detect_lost_tick() and
    instead implementing the lost tick detection code inside mark_offset().
    
    Some of the divs and mods being added here might concern folks, but by not
    calling timer->get_offset() in detect_lost_tick() we eliminate much of the
    same math.  I did some simple cycle counting and the new code comes out on
    average equivalent or faster.
    d9a4b6c5
timer_tsc.c 10.8 KB