• Michal Hocko's avatar
    watchdog: update watchdog_thresh properly · 9809b18f
    Michal Hocko authored
    watchdog_tresh controls how often nmi perf event counter checks per-cpu
    hrtimer_interrupts counter and blows up if the counter hasn't changed
    since the last check.  The counter is updated by per-cpu
    watchdog_hrtimer hrtimer which is scheduled with 2/5 watchdog_thresh
    period which guarantees that hrtimer is scheduled 2 times per the main
    period.  Both hrtimer and perf event are started together when the
    watchdog is enabled.
    
    So far so good.  But...
    
    But what happens when watchdog_thresh is updated from sysctl handler?
    
    proc_dowatchdog will set a new sampling period and hrtimer callback
    (watchdog_timer_fn) will use the new value in the next round.  The
    problem, however, is that nobody tells the perf event that the sampling
    period has changed so it is ticking with the period configured when it
    has been set up.
    
    This might result in an ear ripping dissonance between perf and hrtimer
    parts if the watchdog_thresh is increased.  And even worse it might lead
    to KABOOM if ...
    9809b18f
watchdog.c 15.6 KB