aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2006-12-06 23:37:26 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 11:39:36 -0500
commitd5abe669172f20a4129a711de0f250a4e07db298 (patch)
tree8a1ae8ab51525bfa9e29707f27cc656e2275b247 /kernel
parent6fb50ea79cb869667adaa71ed32cc15dd73986de (diff)
[PATCH] debug: workqueue locking sanity
Workqueue functions should not leak locks, assert so, printing the last function ran. Use macros in lockdep.h to avoid include dependency pains. [akpm@osdl.org: build fix] Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/workqueue.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 2945b094d871..5484d6e045c2 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -30,6 +30,8 @@
30#include <linux/hardirq.h> 30#include <linux/hardirq.h>
31#include <linux/mempolicy.h> 31#include <linux/mempolicy.h>
32#include <linux/freezer.h> 32#include <linux/freezer.h>
33#include <linux/kallsyms.h>
34#include <linux/debug_locks.h>
33 35
34/* 36/*
35 * The per-CPU workqueue (if single thread, we always use the first 37 * The per-CPU workqueue (if single thread, we always use the first
@@ -253,6 +255,17 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
253 work_release(work); 255 work_release(work);
254 f(work); 256 f(work);
255 257
258 if (unlikely(in_atomic() || lockdep_depth(current) > 0)) {
259 printk(KERN_ERR "BUG: workqueue leaked lock or atomic: "
260 "%s/0x%08x/%d\n",
261 current->comm, preempt_count(),
262 current->pid);
263 printk(KERN_ERR " last function: ");
264 print_symbol("%s\n", (unsigned long)f);
265 debug_show_held_locks(current);
266 dump_stack();
267 }
268
256 spin_lock_irqsave(&cwq->lock, flags); 269 spin_lock_irqsave(&cwq->lock, flags);
257 cwq->remove_sequence++; 270 cwq->remove_sequence++;
258 wake_up(&cwq->work_done); 271 wake_up(&cwq->work_done);