diff options
Diffstat (limited to 'include/linux/mutex.h')
-rw-r--r-- | include/linux/mutex.h | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/include/linux/mutex.h b/include/linux/mutex.h index f1ac507fa20d..27c48daa3183 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/list.h> | 13 | #include <linux/list.h> |
14 | #include <linux/spinlock_types.h> | 14 | #include <linux/spinlock_types.h> |
15 | #include <linux/linkage.h> | 15 | #include <linux/linkage.h> |
16 | #include <linux/lockdep.h> | ||
16 | 17 | ||
17 | #include <asm/atomic.h> | 18 | #include <asm/atomic.h> |
18 | 19 | ||
@@ -50,11 +51,12 @@ struct mutex { | |||
50 | struct list_head wait_list; | 51 | struct list_head wait_list; |
51 | #ifdef CONFIG_DEBUG_MUTEXES | 52 | #ifdef CONFIG_DEBUG_MUTEXES |
52 | struct thread_info *owner; | 53 | struct thread_info *owner; |
53 | struct list_head held_list; | ||
54 | unsigned long acquire_ip; | ||
55 | const char *name; | 54 | const char *name; |
56 | void *magic; | 55 | void *magic; |
57 | #endif | 56 | #endif |
57 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
58 | struct lockdep_map dep_map; | ||
59 | #endif | ||
58 | }; | 60 | }; |
59 | 61 | ||
60 | /* | 62 | /* |
@@ -74,24 +76,34 @@ struct mutex_waiter { | |||
74 | # include <linux/mutex-debug.h> | 76 | # include <linux/mutex-debug.h> |
75 | #else | 77 | #else |
76 | # define __DEBUG_MUTEX_INITIALIZER(lockname) | 78 | # define __DEBUG_MUTEX_INITIALIZER(lockname) |
77 | # define mutex_init(mutex) __mutex_init(mutex, NULL) | 79 | # define mutex_init(mutex) \ |
80 | do { \ | ||
81 | static struct lock_class_key __key; \ | ||
82 | \ | ||
83 | __mutex_init((mutex), #mutex, &__key); \ | ||
84 | } while (0) | ||
78 | # define mutex_destroy(mutex) do { } while (0) | 85 | # define mutex_destroy(mutex) do { } while (0) |
79 | # define mutex_debug_show_all_locks() do { } while (0) | 86 | #endif |
80 | # define mutex_debug_show_held_locks(p) do { } while (0) | 87 | |
81 | # define mutex_debug_check_no_locks_held(task) do { } while (0) | 88 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
82 | # define mutex_debug_check_no_locks_freed(from, len) do { } while (0) | 89 | # define __DEP_MAP_MUTEX_INITIALIZER(lockname) \ |
90 | , .dep_map = { .name = #lockname } | ||
91 | #else | ||
92 | # define __DEP_MAP_MUTEX_INITIALIZER(lockname) | ||
83 | #endif | 93 | #endif |
84 | 94 | ||
85 | #define __MUTEX_INITIALIZER(lockname) \ | 95 | #define __MUTEX_INITIALIZER(lockname) \ |
86 | { .count = ATOMIC_INIT(1) \ | 96 | { .count = ATOMIC_INIT(1) \ |
87 | , .wait_lock = SPIN_LOCK_UNLOCKED \ | 97 | , .wait_lock = SPIN_LOCK_UNLOCKED \ |
88 | , .wait_list = LIST_HEAD_INIT(lockname.wait_list) \ | 98 | , .wait_list = LIST_HEAD_INIT(lockname.wait_list) \ |
89 | __DEBUG_MUTEX_INITIALIZER(lockname) } | 99 | __DEBUG_MUTEX_INITIALIZER(lockname) \ |
100 | __DEP_MAP_MUTEX_INITIALIZER(lockname) } | ||
90 | 101 | ||
91 | #define DEFINE_MUTEX(mutexname) \ | 102 | #define DEFINE_MUTEX(mutexname) \ |
92 | struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) | 103 | struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) |
93 | 104 | ||
94 | extern void fastcall __mutex_init(struct mutex *lock, const char *name); | 105 | extern void __mutex_init(struct mutex *lock, const char *name, |
106 | struct lock_class_key *key); | ||
95 | 107 | ||
96 | /*** | 108 | /*** |
97 | * mutex_is_locked - is the mutex locked | 109 | * mutex_is_locked - is the mutex locked |
@@ -110,6 +122,13 @@ static inline int fastcall mutex_is_locked(struct mutex *lock) | |||
110 | */ | 122 | */ |
111 | extern void fastcall mutex_lock(struct mutex *lock); | 123 | extern void fastcall mutex_lock(struct mutex *lock); |
112 | extern int fastcall mutex_lock_interruptible(struct mutex *lock); | 124 | extern int fastcall mutex_lock_interruptible(struct mutex *lock); |
125 | |||
126 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
127 | extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); | ||
128 | #else | ||
129 | # define mutex_lock_nested(lock, subclass) mutex_lock(lock) | ||
130 | #endif | ||
131 | |||
113 | /* | 132 | /* |
114 | * NOTE: mutex_trylock() follows the spin_trylock() convention, | 133 | * NOTE: mutex_trylock() follows the spin_trylock() convention, |
115 | * not the down_trylock() convention! | 134 | * not the down_trylock() convention! |