[RFC PATCH 3/3] timer: warn when del_timer_sync() used in hardirq context

From: Yong Zhang
Date: Tue Aug 24 2010 - 03:00:19 EST


From: Yong Zhang <yong.zhang@xxxxxxxxxxxxx>

Add explict warning to prevent del_timer_sync() from using
in hardirq context.

Signed-off-by: Yong Zhang <yong.zhang0@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
---
kernel/timer.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index 08c9559..1bc4b4a 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -996,7 +996,11 @@ int del_timer_sync(struct timer_list *timer)
lock_map_release(&timer->lockdep_map);
local_bh_enable();
#endif
-
+ /*
+ * don't use it in hardirq context, because it
+ * could lead to deadlock.
+ */
+ WARN_ON(in_irq());
for (;;) {
int ret = try_to_del_timer_sync(timer);
if (ret >= 0)
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/