diff options
Diffstat (limited to 'kernel/rtmutex-debug.c')
| -rw-r--r-- | kernel/rtmutex-debug.c | 77 |
1 files changed, 12 insertions, 65 deletions
diff --git a/kernel/rtmutex-debug.c b/kernel/rtmutex-debug.c index 3c7cbc2c33be..a2e7e7210f3e 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() \ | ||
| 36 | do { \ | ||
| 37 | if (rt_trace_on) { \ | ||
| 38 | rt_trace_on = 0; \ | ||
| 39 | console_verbose(); \ | ||
| 40 | if (raw_spin_is_locked(¤t->pi_lock)) \ | ||
| 41 | raw_spin_unlock(¤t->pi_lock); \ | ||
| 42 | } \ | ||
| 43 | } while (0) | ||
| 44 | |||
| 45 | # define TRACE_OFF_NOLOCK() \ | ||
| 46 | do { \ | ||
| 47 | if (rt_trace_on) { \ | ||
| 48 | rt_trace_on = 0; \ | ||
| 49 | console_verbose(); \ | ||
| 50 | } \ | ||
| 51 | } while (0) | ||
| 52 | |||
| 53 | # define TRACE_BUG_LOCKED() \ | ||
| 54 | do { \ | ||
| 55 | TRACE_OFF(); \ | ||
| 56 | BUG(); \ | ||
| 57 | } while (0) | ||
| 58 | |||
| 59 | # define TRACE_WARN_ON_LOCKED(c) \ | ||
| 60 | do { \ | ||
| 61 | if (unlikely(c)) { \ | ||
| 62 | TRACE_OFF(); \ | ||
| 63 | WARN_ON(1); \ | ||
| 64 | } \ | ||
| 65 | } while (0) | ||
| 66 | |||
| 67 | # define TRACE_BUG_ON_LOCKED(c) \ | ||
| 68 | do { \ | ||
| 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 | */ | ||
| 85 | static int rt_trace_on = 1; | ||
| 86 | |||
| 87 | static void printk_task(struct task_struct *p) | 32 | static 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 | ||
| 112 | void rt_mutex_debug_task_free(struct task_struct *task) | 57 | void 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,10 @@ 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 | rcu_read_unlock(); | ||
| 99 | return; | ||
| 100 | } | ||
| 153 | 101 | ||
| 154 | printk("\n============================================\n"); | 102 | printk("\n============================================\n"); |
| 155 | printk( "[ BUG: circular locking deadlock detected! ]\n"); | 103 | printk( "[ BUG: circular locking deadlock detected! ]\n"); |
| @@ -180,7 +128,6 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter) | |||
| 180 | 128 | ||
| 181 | printk("[ turning off deadlock detection." | 129 | printk("[ turning off deadlock detection." |
| 182 | "Please report this trace. ]\n\n"); | 130 | "Please report this trace. ]\n\n"); |
| 183 | local_irq_disable(); | ||
| 184 | } | 131 | } |
| 185 | 132 | ||
| 186 | void debug_rt_mutex_lock(struct rt_mutex *lock) | 133 | void debug_rt_mutex_lock(struct rt_mutex *lock) |
| @@ -189,7 +136,7 @@ void debug_rt_mutex_lock(struct rt_mutex *lock) | |||
| 189 | 136 | ||
| 190 | void debug_rt_mutex_unlock(struct rt_mutex *lock) | 137 | void debug_rt_mutex_unlock(struct rt_mutex *lock) |
| 191 | { | 138 | { |
| 192 | TRACE_WARN_ON_LOCKED(rt_mutex_owner(lock) != current); | 139 | DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current); |
| 193 | } | 140 | } |
| 194 | 141 | ||
| 195 | void | 142 | void |
| @@ -199,7 +146,7 @@ debug_rt_mutex_proxy_lock(struct rt_mutex *lock, struct task_struct *powner) | |||
| 199 | 146 | ||
| 200 | void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock) | 147 | void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock) |
| 201 | { | 148 | { |
| 202 | TRACE_WARN_ON_LOCKED(!rt_mutex_owner(lock)); | 149 | DEBUG_LOCKS_WARN_ON(!rt_mutex_owner(lock)); |
| 203 | } | 150 | } |
| 204 | 151 | ||
| 205 | void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter) | 152 | void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter) |
| @@ -213,8 +160,8 @@ void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter) | |||
| 213 | void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter) | 160 | void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter) |
| 214 | { | 161 | { |
| 215 | put_pid(waiter->deadlock_task_pid); | 162 | put_pid(waiter->deadlock_task_pid); |
| 216 | TRACE_WARN_ON(!plist_node_empty(&waiter->list_entry)); | 163 | DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->list_entry)); |
| 217 | TRACE_WARN_ON(!plist_node_empty(&waiter->pi_list_entry)); | 164 | DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->pi_list_entry)); |
| 218 | memset(waiter, 0x22, sizeof(*waiter)); | 165 | memset(waiter, 0x22, sizeof(*waiter)); |
| 219 | } | 166 | } |
| 220 | 167 | ||
