Blame view
kernel/rtmutex-debug.c
4.71 KB
e7eebaf6a [PATCH] pi-futex:... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/* * RT-Mutexes: blocking mutual exclusion locks with PI support * * started by Ingo Molnar and Thomas Gleixner: * * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> * Copyright (C) 2006 Timesys Corp., Thomas Gleixner <tglx@timesys.com> * * This code is based on the rt.c implementation in the preempt-rt tree. * Portions of said code are * * Copyright (C) 2004 LynuxWorks, Inc., Igor Manyilov, Bill Huey * Copyright (C) 2006 Esben Nielsen * Copyright (C) 2006 Kihon Technologies Inc., * Steven Rostedt <rostedt@goodmis.org> * * See rt.c in preempt-rt for proper credits and further information */ |
e7eebaf6a [PATCH] pi-futex:... |
19 |
#include <linux/sched.h> |
8bd75c77b sched/rt: Move rt... |
20 |
#include <linux/sched/rt.h> |
e7eebaf6a [PATCH] pi-futex:... |
21 |
#include <linux/delay.h> |
9984de1a5 kernel: Map most ... |
22 |
#include <linux/export.h> |
e7eebaf6a [PATCH] pi-futex:... |
23 24 25 26 27 28 |
#include <linux/spinlock.h> #include <linux/kallsyms.h> #include <linux/syscalls.h> #include <linux/interrupt.h> #include <linux/plist.h> #include <linux/fs.h> |
9a11b49a8 [PATCH] lockdep: ... |
29 |
#include <linux/debug_locks.h> |
e7eebaf6a [PATCH] pi-futex:... |
30 31 |
#include "rtmutex_common.h" |
36c8b5868 [PATCH] sched: cl... |
32 |
static void printk_task(struct task_struct *p) |
e7eebaf6a [PATCH] pi-futex:... |
33 34 |
{ if (p) |
ba25f9dcc Use helpers to ob... |
35 |
printk("%16s:%5d [%p, %3d]", p->comm, task_pid_nr(p), p, p->prio); |
e7eebaf6a [PATCH] pi-futex:... |
36 37 38 |
else printk("<none>"); } |
e7eebaf6a [PATCH] pi-futex:... |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
static void printk_lock(struct rt_mutex *lock, int print_owner) { if (lock->name) printk(" [%p] {%s} ", lock, lock->name); else printk(" [%p] {%s:%d} ", lock, lock->file, lock->line); if (print_owner && rt_mutex_owner(lock)) { printk(".. ->owner: %p ", lock->owner); printk(".. held by: "); printk_task(rt_mutex_owner(lock)); printk(" "); } |
e7eebaf6a [PATCH] pi-futex:... |
58 59 60 61 |
} void rt_mutex_debug_task_free(struct task_struct *task) { |
0fa914c63 rtmutex: Cleanup ... |
62 63 |
DEBUG_LOCKS_WARN_ON(!plist_head_empty(&task->pi_waiters)); DEBUG_LOCKS_WARN_ON(task->pi_blocked_on); |
e7eebaf6a [PATCH] pi-futex:... |
64 65 66 67 68 69 70 71 72 73 74 |
} /* * We fill out the fields in the waiter to store the information about * the deadlock. We print when we return. act_waiter can be NULL in * case of a remove waiter operation. */ void debug_rt_mutex_deadlock(int detect, struct rt_mutex_waiter *act_waiter, struct rt_mutex *lock) { struct task_struct *task; |
0fa914c63 rtmutex: Cleanup ... |
75 |
if (!debug_locks || detect || !act_waiter) |
e7eebaf6a [PATCH] pi-futex:... |
76 77 78 79 |
return; task = rt_mutex_owner(act_waiter->lock); if (task && task != current) { |
48d13e483 Don't operate wit... |
80 |
act_waiter->deadlock_task_pid = get_pid(task_pid(task)); |
e7eebaf6a [PATCH] pi-futex:... |
81 82 83 84 85 86 87 |
act_waiter->deadlock_lock = lock; } } void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter) { struct task_struct *task; |
0fa914c63 rtmutex: Cleanup ... |
88 |
if (!waiter->deadlock_lock || !debug_locks) |
e7eebaf6a [PATCH] pi-futex:... |
89 |
return; |
48d13e483 Don't operate wit... |
90 91 92 93 |
rcu_read_lock(); task = pid_task(waiter->deadlock_task_pid, PIDTYPE_PID); if (!task) { rcu_read_unlock(); |
e7eebaf6a [PATCH] pi-futex:... |
94 |
return; |
48d13e483 Don't operate wit... |
95 |
} |
e7eebaf6a [PATCH] pi-futex:... |
96 |
|
68cc3990a rtmutex: Add miss... |
97 98 |
if (!debug_locks_off()) { rcu_read_unlock(); |
0fa914c63 rtmutex: Cleanup ... |
99 |
return; |
68cc3990a rtmutex: Add miss... |
100 |
} |
e7eebaf6a [PATCH] pi-futex:... |
101 102 103 104 105 106 |
printk(" ============================================ "); printk( "[ BUG: circular locking deadlock detected! ] "); |
fbdc4b9a6 lockdep, rtmutex,... |
107 108 |
printk("%s ", print_tainted()); |
e7eebaf6a [PATCH] pi-futex:... |
109 110 111 112 113 |
printk( "-------------------------------------------- "); printk("%s/%d is deadlocking current task %s/%d ", |
ba25f9dcc Use helpers to ob... |
114 115 |
task->comm, task_pid_nr(task), current->comm, task_pid_nr(current)); |
e7eebaf6a [PATCH] pi-futex:... |
116 117 118 119 |
printk(" 1) %s/%d is trying to acquire this lock: ", |
ba25f9dcc Use helpers to ob... |
120 |
current->comm, task_pid_nr(current)); |
e7eebaf6a [PATCH] pi-futex:... |
121 |
printk_lock(waiter->lock, 1); |
ba25f9dcc Use helpers to ob... |
122 123 124 125 |
printk(" 2) %s/%d is blocked on this lock: ", task->comm, task_pid_nr(task)); |
e7eebaf6a [PATCH] pi-futex:... |
126 |
printk_lock(waiter->deadlock_lock, 1); |
9a11b49a8 [PATCH] lockdep: ... |
127 128 |
debug_show_held_locks(current); debug_show_held_locks(task); |
e7eebaf6a [PATCH] pi-futex:... |
129 |
|
ba25f9dcc Use helpers to ob... |
130 131 132 133 134 |
printk(" %s/%d's [blocked] stackdump: ", task->comm, task_pid_nr(task)); |
e7eebaf6a [PATCH] pi-futex:... |
135 136 137 138 139 |
show_stack(task, NULL); printk(" %s/%d's [current] stackdump: ", |
ba25f9dcc Use helpers to ob... |
140 |
current->comm, task_pid_nr(current)); |
e7eebaf6a [PATCH] pi-futex:... |
141 |
dump_stack(); |
9a11b49a8 [PATCH] lockdep: ... |
142 |
debug_show_all_locks(); |
48d13e483 Don't operate wit... |
143 |
rcu_read_unlock(); |
9a11b49a8 [PATCH] lockdep: ... |
144 |
|
e7eebaf6a [PATCH] pi-futex:... |
145 146 147 148 |
printk("[ turning off deadlock detection." "Please report this trace. ] "); |
e7eebaf6a [PATCH] pi-futex:... |
149 |
} |
9a11b49a8 [PATCH] lockdep: ... |
150 |
void debug_rt_mutex_lock(struct rt_mutex *lock) |
e7eebaf6a [PATCH] pi-futex:... |
151 |
{ |
e7eebaf6a [PATCH] pi-futex:... |
152 153 154 155 |
} void debug_rt_mutex_unlock(struct rt_mutex *lock) { |
0fa914c63 rtmutex: Cleanup ... |
156 |
DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current); |
e7eebaf6a [PATCH] pi-futex:... |
157 |
} |
9a11b49a8 [PATCH] lockdep: ... |
158 159 |
void debug_rt_mutex_proxy_lock(struct rt_mutex *lock, struct task_struct *powner) |
e7eebaf6a [PATCH] pi-futex:... |
160 |
{ |
e7eebaf6a [PATCH] pi-futex:... |
161 162 163 164 |
} void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock) { |
0fa914c63 rtmutex: Cleanup ... |
165 |
DEBUG_LOCKS_WARN_ON(!rt_mutex_owner(lock)); |
e7eebaf6a [PATCH] pi-futex:... |
166 167 168 169 170 171 172 |
} void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter) { memset(waiter, 0x11, sizeof(*waiter)); plist_node_init(&waiter->list_entry, MAX_PRIO); plist_node_init(&waiter->pi_list_entry, MAX_PRIO); |
48d13e483 Don't operate wit... |
173 |
waiter->deadlock_task_pid = NULL; |
e7eebaf6a [PATCH] pi-futex:... |
174 175 176 177 |
} void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter) { |
48d13e483 Don't operate wit... |
178 |
put_pid(waiter->deadlock_task_pid); |
0fa914c63 rtmutex: Cleanup ... |
179 180 |
DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->list_entry)); DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->pi_list_entry)); |
e7eebaf6a [PATCH] pi-futex:... |
181 182 183 184 185 |
memset(waiter, 0x22, sizeof(*waiter)); } void debug_rt_mutex_init(struct rt_mutex *lock, const char *name) { |
9a11b49a8 [PATCH] lockdep: ... |
186 187 188 189 190 |
/* * Make sure we are not reinitializing a held lock: */ debug_check_no_locks_freed((void *)lock, sizeof(*lock)); lock->name = name; |
e7eebaf6a [PATCH] pi-futex:... |
191 |
} |
36c8b5868 [PATCH] sched: cl... |
192 193 |
void rt_mutex_deadlock_account_lock(struct rt_mutex *lock, struct task_struct *task) |
e7eebaf6a [PATCH] pi-futex:... |
194 195 196 197 198 199 |
{ } void rt_mutex_deadlock_account_unlock(struct task_struct *task) { } |