aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/timer.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2010-03-12 14:13:23 -0500
committerThomas Gleixner <tglx@linutronix.de>2010-03-12 16:40:44 -0500
commit802702e0c2618465b813242d4dfee6a233ba0beb (patch)
treee21c74065e82a77c45c4f815c626fbafc7fff469 /kernel/timer.c
parent576da126a6c7364d70dfd58d0bbe43d05cf5859f (diff)
timer: Try to survive timer callback preempt_count leak
If a timer callback leaks preempt_count we currently assert a BUG(). That makes it unnecessarily hard to retrieve information about the problem especially on laptops and headless stations. There is a decent chance to survive the preempt_count leak by restoring the preempt_count to the value before the callback. That allows in many cases to get valuable information about the root cause of the problem. We carried that fixup in preempt-rt for years and were able to decode such wreckage quite a few times. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Linux Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arjan van de Veen <arjan@infradead.org>
Diffstat (limited to 'kernel/timer.c')
-rw-r--r--kernel/timer.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/kernel/timer.c b/kernel/timer.c
index 45229694dc6a..7e12e7bc7ce6 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -982,9 +982,15 @@ static void call_timer_fn(struct timer_list *timer, void (*fn)(unsigned long),
982 lock_map_release(&lockdep_map); 982 lock_map_release(&lockdep_map);
983 983
984 if (preempt_count != preempt_count()) { 984 if (preempt_count != preempt_count()) {
985 printk(KERN_ERR "timer: %pF preempt leak: %08x -> %08x\n", 985 WARN_ONCE(1, "timer: %pF preempt leak: %08x -> %08x\n",
986 fn, preempt_count, preempt_count()); 986 fn, preempt_count, preempt_count());
987 BUG(); 987 /*
988 * Restore the preempt count. That gives us a decent
989 * chance to survive and extract information. If the
990 * callback kept a lock held, bad luck, but not worse
991 * than the BUG() we had.
992 */
993 preempt_count() = preempt_count;
988 } 994 }
989} 995}
990 996