• Thomas Gleixner's avatar
    tick: Clear broadcast active bit when switching to oneshot · 07f4beb0
    Thomas Gleixner authored
    The first cpu which switches from periodic to oneshot mode switches
    also the broadcast device into oneshot mode. The broadcast device
    serves as a backup for per cpu timers which stop in deeper
    C-states. To avoid starvation of the cpus which might be in idle and
    depend on broadcast mode it marks the other cpus as broadcast active
    and sets the brodcast expiry value of those cpus to the next tick.
    
    The oneshot mode broadcast bit for the other cpus is sticky and gets
    only cleared when those cpus exit idle. If a cpu was not idle while
    the bit got set in consequence the bit prevents that the broadcast
    device is armed on behalf of that cpu when it enters idle for the
    first time after it switched to oneshot mode.
    
    In most cases that goes unnoticed as one of the other cpus has usually
    a timer pending which keeps the broadcast device armed with a short
    timeout. Now if the only cpu which has a short timer active has the
    bit set then the broadcast device will not be armed on behalf of that
    cpu and will fire way after the expected timer expiry. In the case of
    Christians bug report it took ~145 seconds which is about half of the
    wrap around time of HPET (the limit for that device) due to the fact
    that all other cpus had no timers armed which expired before the 145
    seconds timeframe.
    
    The solution is simply to clear the broadcast active bit
    unconditionally when a cpu switches to oneshot mode after the first
    cpu switched the broadcast device over. It's not idle at that point
    otherwise it would not be executing that code.
    
    [ I fundamentally hate that broadcast crap. Why the heck thought some
      folks that when going into deep idle it's a brilliant concept to
      switch off the last device which brings the cpu back from that
      state? ]
    
    Thanks to Christian for providing all the valuable debug information!
    Reported-and-tested-by: default avatarChristian Hoffmann <email@christianhoffmann.info>
    Cc: John Stultz <johnstul@us.ibm.com>
    Link: http://lkml.kernel.org/r/%3Calpine.LFD.2.02.1105161105170.3078%40ionos%3E
    Cc: stable@kernel.org
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    07f4beb0
tick-broadcast.c 15.4 KB