aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rtmutex-debug.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2011-06-08 03:58:38 -0400
committerThomas Gleixner <tglx@linutronix.de>2011-09-12 07:42:32 -0400
commit0fa914c632210e09940f0bf5b85d2329b75e04e0 (patch)
tree964dd641a78cb49a9103104dc8a759c4ebf3d322 /kernel/rtmutex-debug.c
parentd0a77454c70d0449a5f87087deb8f0cb15145e90 (diff)
rtmutex: Cleanup the debug code
Use the existing lock debugging macros. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/rtmutex-debug.c')
-rw-r--r--kernel/rtmutex-debug.c75
1 files changed, 10 insertions, 65 deletions
diff --git a/kernel/rtmutex-debug.c b/kernel/rtmutex-debug.c
index 3c7cbc2c33be..cb1ced6967ad 100644
--- a/kernel/rtmutex-debug.c
+++ b/kernel/rtmutex-debug.c
@@ -29,61 +29,6 @@
29 29
30#include "rtmutex_common.h" 30#include "rtmutex_common.h"
31 31
32# define TRACE_WARN_ON(x) WARN_ON(x)
33# define TRACE_BUG_ON(x) BUG_ON(x)
34
35# define TRACE_OFF() \
36do { \
37 if (rt_trace_on) { \
38 rt_trace_on = 0; \
39 console_verbose(); \
40 if (raw_spin_is_locked(&current->pi_lock)) \
41 raw_spin_unlock(&current->pi_lock); \
42 } \
43} while (0)
44
45# define TRACE_OFF_NOLOCK() \
46do { \
47 if (rt_trace_on) { \
48 rt_trace_on = 0; \
49 console_verbose(); \
50 } \
51} while (0)
52
53# define TRACE_BUG_LOCKED() \
54do { \
55 TRACE_OFF(); \
56 BUG(); \
57} while (0)
58
59# define TRACE_WARN_ON_LOCKED(c) \
60do { \
61 if (unlikely(c)) { \
62 TRACE_OFF(); \
63 WARN_ON(1); \
64 } \
65} while (0)
66
67# define TRACE_BUG_ON_LOCKED(c) \
68do { \
69 if (unlikely(c)) \
70 TRACE_BUG_LOCKED(); \
71} while (0)
72
73#ifdef CONFIG_SMP
74# define SMP_TRACE_BUG_ON_LOCKED(c) TRACE_BUG_ON_LOCKED(c)
75#else
76# define SMP_TRACE_BUG_ON_LOCKED(c) do { } while (0)
77#endif
78
79/*
80 * deadlock detection flag. We turn it off when we detect
81 * the first problem because we dont want to recurse back
82 * into the tracing code when doing error printk or
83 * executing a BUG():
84 */
85static int rt_trace_on = 1;
86
87static void printk_task(struct task_struct *p) 32static void printk_task(struct task_struct *p)
88{ 33{
89 if (p) 34 if (p)
@@ -111,8 +56,8 @@ static void printk_lock(struct rt_mutex *lock, int print_owner)
111 56
112void rt_mutex_debug_task_free(struct task_struct *task) 57void rt_mutex_debug_task_free(struct task_struct *task)
113{ 58{
114 WARN_ON(!plist_head_empty(&task->pi_waiters)); 59 DEBUG_LOCKS_WARN_ON(!plist_head_empty(&task->pi_waiters));
115 WARN_ON(task->pi_blocked_on); 60 DEBUG_LOCKS_WARN_ON(task->pi_blocked_on);
116} 61}
117 62
118/* 63/*
@@ -125,7 +70,7 @@ void debug_rt_mutex_deadlock(int detect, struct rt_mutex_waiter *act_waiter,
125{ 70{
126 struct task_struct *task; 71 struct task_struct *task;
127 72
128 if (!rt_trace_on || detect || !act_waiter) 73 if (!debug_locks || detect || !act_waiter)
129 return; 74 return;
130 75
131 task = rt_mutex_owner(act_waiter->lock); 76 task = rt_mutex_owner(act_waiter->lock);
@@ -139,7 +84,7 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
139{ 84{
140 struct task_struct *task; 85 struct task_struct *task;
141 86
142 if (!waiter->deadlock_lock || !rt_trace_on) 87 if (!waiter->deadlock_lock || !debug_locks)
143 return; 88 return;
144 89
145 rcu_read_lock(); 90 rcu_read_lock();
@@ -149,7 +94,8 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
149 return; 94 return;
150 } 95 }
151 96
152 TRACE_OFF_NOLOCK(); 97 if (!debug_locks_off())
98 return;
153 99
154 printk("\n============================================\n"); 100 printk("\n============================================\n");
155 printk( "[ BUG: circular locking deadlock detected! ]\n"); 101 printk( "[ BUG: circular locking deadlock detected! ]\n");
@@ -180,7 +126,6 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
180 126
181 printk("[ turning off deadlock detection." 127 printk("[ turning off deadlock detection."
182 "Please report this trace. ]\n\n"); 128 "Please report this trace. ]\n\n");
183 local_irq_disable();
184} 129}
185 130
186void debug_rt_mutex_lock(struct rt_mutex *lock) 131void debug_rt_mutex_lock(struct rt_mutex *lock)
@@ -189,7 +134,7 @@ void debug_rt_mutex_lock(struct rt_mutex *lock)
189 134
190void debug_rt_mutex_unlock(struct rt_mutex *lock) 135void debug_rt_mutex_unlock(struct rt_mutex *lock)
191{ 136{
192 TRACE_WARN_ON_LOCKED(rt_mutex_owner(lock) != current); 137 DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current);
193} 138}
194 139
195void 140void
@@ -199,7 +144,7 @@ debug_rt_mutex_proxy_lock(struct rt_mutex *lock, struct task_struct *powner)
199 144
200void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock) 145void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock)
201{ 146{
202 TRACE_WARN_ON_LOCKED(!rt_mutex_owner(lock)); 147 DEBUG_LOCKS_WARN_ON(!rt_mutex_owner(lock));
203} 148}
204 149
205void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter) 150void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter)
@@ -213,8 +158,8 @@ void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter)
213void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter) 158void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter)
214{ 159{
215 put_pid(waiter->deadlock_task_pid); 160 put_pid(waiter->deadlock_task_pid);
216 TRACE_WARN_ON(!plist_node_empty(&waiter->list_entry)); 161 DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->list_entry));
217 TRACE_WARN_ON(!plist_node_empty(&waiter->pi_list_entry)); 162 DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->pi_list_entry));
218 memset(waiter, 0x22, sizeof(*waiter)); 163 memset(waiter, 0x22, sizeof(*waiter));
219} 164}
220 165