.. | .. |
---|
14 | 14 | #define __LINUX_RT_MUTEX_H |
---|
15 | 15 | |
---|
16 | 16 | #include <linux/linkage.h> |
---|
17 | | -#include <linux/rbtree_type.h> |
---|
18 | | -#include <linux/spinlock_types_raw.h> |
---|
| 17 | +#include <linux/rbtree.h> |
---|
| 18 | +#include <linux/spinlock_types.h> |
---|
19 | 19 | |
---|
20 | 20 | extern int max_lock_depth; /* for sysctl */ |
---|
21 | | - |
---|
22 | | -#ifdef CONFIG_DEBUG_MUTEXES |
---|
23 | | -#include <linux/debug_locks.h> |
---|
24 | | -#endif |
---|
25 | 21 | |
---|
26 | 22 | /** |
---|
27 | 23 | * The rt_mutex structure |
---|
.. | .. |
---|
35 | 31 | raw_spinlock_t wait_lock; |
---|
36 | 32 | struct rb_root_cached waiters; |
---|
37 | 33 | struct task_struct *owner; |
---|
| 34 | +#ifdef CONFIG_DEBUG_RT_MUTEXES |
---|
38 | 35 | int save_state; |
---|
| 36 | + const char *name, *file; |
---|
| 37 | + int line; |
---|
| 38 | + void *magic; |
---|
| 39 | +#endif |
---|
39 | 40 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
---|
40 | 41 | struct lockdep_map dep_map; |
---|
41 | 42 | #endif |
---|
.. | .. |
---|
48 | 49 | extern int rt_mutex_debug_check_no_locks_freed(const void *from, |
---|
49 | 50 | unsigned long len); |
---|
50 | 51 | extern void rt_mutex_debug_check_no_locks_held(struct task_struct *task); |
---|
51 | | - extern void rt_mutex_debug_task_free(struct task_struct *tsk); |
---|
52 | 52 | #else |
---|
53 | 53 | static inline int rt_mutex_debug_check_no_locks_freed(const void *from, |
---|
54 | 54 | unsigned long len) |
---|
.. | .. |
---|
56 | 56 | return 0; |
---|
57 | 57 | } |
---|
58 | 58 | # define rt_mutex_debug_check_no_locks_held(task) do { } while (0) |
---|
59 | | -# define rt_mutex_debug_task_free(t) do { } while (0) |
---|
60 | 59 | #endif |
---|
61 | 60 | |
---|
62 | | -#define rt_mutex_init(mutex) \ |
---|
| 61 | +#ifdef CONFIG_DEBUG_RT_MUTEXES |
---|
| 62 | +# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \ |
---|
| 63 | + , .name = #mutexname, .file = __FILE__, .line = __LINE__ |
---|
| 64 | + |
---|
| 65 | +# define rt_mutex_init(mutex) \ |
---|
63 | 66 | do { \ |
---|
64 | 67 | static struct lock_class_key __key; \ |
---|
65 | 68 | __rt_mutex_init(mutex, __func__, &__key); \ |
---|
66 | 69 | } while (0) |
---|
| 70 | + |
---|
| 71 | + extern void rt_mutex_debug_task_free(struct task_struct *tsk); |
---|
| 72 | +#else |
---|
| 73 | +# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) |
---|
| 74 | +# define rt_mutex_init(mutex) __rt_mutex_init(mutex, NULL, NULL) |
---|
| 75 | +# define rt_mutex_debug_task_free(t) do { } while (0) |
---|
| 76 | +#endif |
---|
67 | 77 | |
---|
68 | 78 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
---|
69 | 79 | #define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) \ |
---|
.. | .. |
---|
72 | 82 | #define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) |
---|
73 | 83 | #endif |
---|
74 | 84 | |
---|
75 | | -#define __RT_MUTEX_INITIALIZER_PLAIN(mutexname) \ |
---|
76 | | - .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \ |
---|
| 85 | +#define __RT_MUTEX_INITIALIZER(mutexname) \ |
---|
| 86 | + { .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \ |
---|
77 | 87 | , .waiters = RB_ROOT_CACHED \ |
---|
78 | 88 | , .owner = NULL \ |
---|
79 | | - __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) |
---|
80 | | - |
---|
81 | | -#define __RT_MUTEX_INITIALIZER(mutexname) \ |
---|
82 | | - { __RT_MUTEX_INITIALIZER_PLAIN(mutexname) \ |
---|
83 | | - , .save_state = 0 } |
---|
84 | | - |
---|
85 | | -#define __RT_MUTEX_INITIALIZER_SAVE_STATE(mutexname) \ |
---|
86 | | - { __RT_MUTEX_INITIALIZER_PLAIN(mutexname) \ |
---|
87 | | - , .save_state = 1 } |
---|
| 89 | + __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \ |
---|
| 90 | + __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname)} |
---|
88 | 91 | |
---|
89 | 92 | #define DEFINE_RT_MUTEX(mutexname) \ |
---|
90 | 93 | struct rt_mutex mutexname = __RT_MUTEX_INITIALIZER(mutexname) |
---|
.. | .. |
---|
112 | 115 | #endif |
---|
113 | 116 | |
---|
114 | 117 | extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); |
---|
| 118 | +extern int rt_mutex_timed_lock(struct rt_mutex *lock, |
---|
| 119 | + struct hrtimer_sleeper *timeout); |
---|
| 120 | + |
---|
115 | 121 | extern int rt_mutex_trylock(struct rt_mutex *lock); |
---|
116 | 122 | |
---|
117 | 123 | extern void rt_mutex_unlock(struct rt_mutex *lock); |
---|