Skip to content

Commit 4a6bca2

Browse files
Stuart Hayeshemantbeast
authored andcommitted
hrtimer: Prevent all reprogramming if hang detected
commit 6c6c0d5a1c949d2e084706f9e5fb1fccc175b265 upstream. If the last hrtimer interrupt detected a hang it sets hang_detected=1 and programs the clock event device with a delay to let the system make progress. If hang_detected == 1, we prevent reprogramming of the clock event device in hrtimer_reprogram() but not in hrtimer_force_reprogram(). This can lead to the following situation: hrtimer_interrupt() hang_detected = 1; program ce device to Xms from now (hang delay) We have two timers pending: T1 expires 50ms from now T2 expires 5s from now Now T1 gets canceled, which causes hrtimer_force_reprogram() to be invoked, which in turn programs the clock event device to T2 (5 seconds from now). Any hrtimer_start after that will not reprogram the hardware due to hang_detected still being set. So we effectivly block all timers until the T2 event fires and cleans up the hang situation. Add a check for hang_detected to hrtimer_force_reprogram() which prevents the reprogramming of the hang delay in the hardware timer. The subsequent hrtimer_interrupt will resolve all outstanding issues. [ tglx: Rewrote subject and changelog and fixed up the comment in hrtimer_force_reprogram() ] Change-Id: I5fae69821fdc9173bce5db8590d89467443f4c3f Signed-off-by: Stuart Hayes <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e73de59 commit 4a6bca2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

kernel/hrtimer.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,23 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
568568

569569
cpu_base->expires_next.tv64 = expires_next.tv64;
570570

571+
/*
572+
* If a hang was detected in the last timer interrupt then we
573+
* leave the hang delay active in the hardware. We want the
574+
* system to make progress. That also prevents the following
575+
* scenario:
576+
* T1 expires 50ms from now
577+
* T2 expires 5s from now
578+
*
579+
* T1 is removed, so this code is called and would reprogram
580+
* the hardware to 5s from now. Any hrtimer_start after that
581+
* will not reprogram the hardware due to hang_detected being
582+
* set. So we'd effectivly block all timers until the T2 event
583+
* fires.
584+
*/
585+
if (cpu_base->hang_detected)
586+
return;
587+
571588
if (cpu_base->expires_next.tv64 != KTIME_MAX)
572589
tick_program_event(cpu_base->expires_next, 1);
573590
}

0 commit comments

Comments
 (0)