diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/lockdep.h | 50 | ||||
| -rw-r--r-- | include/linux/mutex.h | 5 | ||||
| -rw-r--r-- | include/linux/sched.h | 3 | ||||
| -rw-r--r-- | include/linux/timer.h | 93 |
4 files changed, 102 insertions, 49 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 23bf02fb124f..5a58ea3e91e9 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h | |||
| @@ -20,43 +20,10 @@ struct lockdep_map; | |||
| 20 | #include <linux/stacktrace.h> | 20 | #include <linux/stacktrace.h> |
| 21 | 21 | ||
| 22 | /* | 22 | /* |
| 23 | * Lock-class usage-state bits: | 23 | * We'd rather not expose kernel/lockdep_states.h this wide, but we do need |
| 24 | * the total number of states... :-( | ||
| 24 | */ | 25 | */ |
| 25 | enum lock_usage_bit | 26 | #define XXX_LOCK_USAGE_STATES (1+3*4) |
| 26 | { | ||
| 27 | LOCK_USED = 0, | ||
| 28 | LOCK_USED_IN_HARDIRQ, | ||
| 29 | LOCK_USED_IN_SOFTIRQ, | ||
| 30 | LOCK_ENABLED_SOFTIRQS, | ||
| 31 | LOCK_ENABLED_HARDIRQS, | ||
| 32 | LOCK_USED_IN_HARDIRQ_READ, | ||
| 33 | LOCK_USED_IN_SOFTIRQ_READ, | ||
| 34 | LOCK_ENABLED_SOFTIRQS_READ, | ||
| 35 | LOCK_ENABLED_HARDIRQS_READ, | ||
| 36 | LOCK_USAGE_STATES | ||
| 37 | }; | ||
| 38 | |||
| 39 | /* | ||
| 40 | * Usage-state bitmasks: | ||
| 41 | */ | ||
| 42 | #define LOCKF_USED (1 << LOCK_USED) | ||
| 43 | #define LOCKF_USED_IN_HARDIRQ (1 << LOCK_USED_IN_HARDIRQ) | ||
| 44 | #define LOCKF_USED_IN_SOFTIRQ (1 << LOCK_USED_IN_SOFTIRQ) | ||
| 45 | #define LOCKF_ENABLED_HARDIRQS (1 << LOCK_ENABLED_HARDIRQS) | ||
| 46 | #define LOCKF_ENABLED_SOFTIRQS (1 << LOCK_ENABLED_SOFTIRQS) | ||
| 47 | |||
| 48 | #define LOCKF_ENABLED_IRQS (LOCKF_ENABLED_HARDIRQS | LOCKF_ENABLED_SOFTIRQS) | ||
| 49 | #define LOCKF_USED_IN_IRQ (LOCKF_USED_IN_HARDIRQ | LOCKF_USED_IN_SOFTIRQ) | ||
| 50 | |||
| 51 | #define LOCKF_USED_IN_HARDIRQ_READ (1 << LOCK_USED_IN_HARDIRQ_READ) | ||
| 52 | #define LOCKF_USED_IN_SOFTIRQ_READ (1 << LOCK_USED_IN_SOFTIRQ_READ) | ||
| 53 | #define LOCKF_ENABLED_HARDIRQS_READ (1 << LOCK_ENABLED_HARDIRQS_READ) | ||
| 54 | #define LOCKF_ENABLED_SOFTIRQS_READ (1 << LOCK_ENABLED_SOFTIRQS_READ) | ||
| 55 | |||
| 56 | #define LOCKF_ENABLED_IRQS_READ \ | ||
| 57 | (LOCKF_ENABLED_HARDIRQS_READ | LOCKF_ENABLED_SOFTIRQS_READ) | ||
| 58 | #define LOCKF_USED_IN_IRQ_READ \ | ||
| 59 | (LOCKF_USED_IN_HARDIRQ_READ | LOCKF_USED_IN_SOFTIRQ_READ) | ||
| 60 | 27 | ||
| 61 | #define MAX_LOCKDEP_SUBCLASSES 8UL | 28 | #define MAX_LOCKDEP_SUBCLASSES 8UL |
| 62 | 29 | ||
| @@ -97,7 +64,7 @@ struct lock_class { | |||
| 97 | * IRQ/softirq usage tracking bits: | 64 | * IRQ/softirq usage tracking bits: |
| 98 | */ | 65 | */ |
| 99 | unsigned long usage_mask; | 66 | unsigned long usage_mask; |
| 100 | struct stack_trace usage_traces[LOCK_USAGE_STATES]; | 67 | struct stack_trace usage_traces[XXX_LOCK_USAGE_STATES]; |
| 101 | 68 | ||
| 102 | /* | 69 | /* |
| 103 | * These fields represent a directed graph of lock dependencies, | 70 | * These fields represent a directed graph of lock dependencies, |
| @@ -324,7 +291,11 @@ static inline void lock_set_subclass(struct lockdep_map *lock, | |||
| 324 | lock_set_class(lock, lock->name, lock->key, subclass, ip); | 291 | lock_set_class(lock, lock->name, lock->key, subclass, ip); |
| 325 | } | 292 | } |
| 326 | 293 | ||
| 327 | # define INIT_LOCKDEP .lockdep_recursion = 0, | 294 | extern void lockdep_set_current_reclaim_state(gfp_t gfp_mask); |
| 295 | extern void lockdep_clear_current_reclaim_state(void); | ||
| 296 | extern void lockdep_trace_alloc(gfp_t mask); | ||
| 297 | |||
| 298 | # define INIT_LOCKDEP .lockdep_recursion = 0, .lockdep_reclaim_gfp = 0, | ||
| 328 | 299 | ||
| 329 | #define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0) | 300 | #define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0) |
| 330 | 301 | ||
| @@ -342,6 +313,9 @@ static inline void lockdep_on(void) | |||
| 342 | # define lock_release(l, n, i) do { } while (0) | 313 | # define lock_release(l, n, i) do { } while (0) |
| 343 | # define lock_set_class(l, n, k, s, i) do { } while (0) | 314 | # define lock_set_class(l, n, k, s, i) do { } while (0) |
| 344 | # define lock_set_subclass(l, s, i) do { } while (0) | 315 | # define lock_set_subclass(l, s, i) do { } while (0) |
| 316 | # define lockdep_set_current_reclaim_state(g) do { } while (0) | ||
| 317 | # define lockdep_clear_current_reclaim_state() do { } while (0) | ||
| 318 | # define lockdep_trace_alloc(g) do { } while (0) | ||
| 345 | # define lockdep_init() do { } while (0) | 319 | # define lockdep_init() do { } while (0) |
| 346 | # define lockdep_info() do { } while (0) | 320 | # define lockdep_info() do { } while (0) |
| 347 | # define lockdep_init_map(lock, name, key, sub) \ | 321 | # define lockdep_init_map(lock, name, key, sub) \ |
diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 7a0e5c4f8072..3069ec7e0ab8 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h | |||
| @@ -50,8 +50,10 @@ struct mutex { | |||
| 50 | atomic_t count; | 50 | atomic_t count; |
| 51 | spinlock_t wait_lock; | 51 | spinlock_t wait_lock; |
| 52 | struct list_head wait_list; | 52 | struct list_head wait_list; |
| 53 | #ifdef CONFIG_DEBUG_MUTEXES | 53 | #if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) |
| 54 | struct thread_info *owner; | 54 | struct thread_info *owner; |
| 55 | #endif | ||
| 56 | #ifdef CONFIG_DEBUG_MUTEXES | ||
| 55 | const char *name; | 57 | const char *name; |
| 56 | void *magic; | 58 | void *magic; |
| 57 | #endif | 59 | #endif |
| @@ -68,7 +70,6 @@ struct mutex_waiter { | |||
| 68 | struct list_head list; | 70 | struct list_head list; |
| 69 | struct task_struct *task; | 71 | struct task_struct *task; |
| 70 | #ifdef CONFIG_DEBUG_MUTEXES | 72 | #ifdef CONFIG_DEBUG_MUTEXES |
| 71 | struct mutex *lock; | ||
| 72 | void *magic; | 73 | void *magic; |
| 73 | #endif | 74 | #endif |
| 74 | }; | 75 | }; |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 1d19c025f9d2..29df6374d2de 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -331,7 +331,9 @@ extern signed long schedule_timeout(signed long timeout); | |||
| 331 | extern signed long schedule_timeout_interruptible(signed long timeout); | 331 | extern signed long schedule_timeout_interruptible(signed long timeout); |
| 332 | extern signed long schedule_timeout_killable(signed long timeout); | 332 | extern signed long schedule_timeout_killable(signed long timeout); |
| 333 | extern signed long schedule_timeout_uninterruptible(signed long timeout); | 333 | extern signed long schedule_timeout_uninterruptible(signed long timeout); |
| 334 | asmlinkage void __schedule(void); | ||
| 334 | asmlinkage void schedule(void); | 335 | asmlinkage void schedule(void); |
| 336 | extern int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner); | ||
| 335 | 337 | ||
| 336 | struct nsproxy; | 338 | struct nsproxy; |
| 337 | struct user_namespace; | 339 | struct user_namespace; |
| @@ -1334,6 +1336,7 @@ struct task_struct { | |||
| 1334 | int lockdep_depth; | 1336 | int lockdep_depth; |
| 1335 | unsigned int lockdep_recursion; | 1337 | unsigned int lockdep_recursion; |
| 1336 | struct held_lock held_locks[MAX_LOCK_DEPTH]; | 1338 | struct held_lock held_locks[MAX_LOCK_DEPTH]; |
| 1339 | gfp_t lockdep_reclaim_gfp; | ||
| 1337 | #endif | 1340 | #endif |
| 1338 | 1341 | ||
| 1339 | /* journalling filesystem info */ | 1342 | /* journalling filesystem info */ |
diff --git a/include/linux/timer.h b/include/linux/timer.h index e2d662e3416e..6cdb6f3331f1 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <linux/ktime.h> | 5 | #include <linux/ktime.h> |
| 6 | #include <linux/stddef.h> | 6 | #include <linux/stddef.h> |
| 7 | #include <linux/debugobjects.h> | 7 | #include <linux/debugobjects.h> |
| 8 | #include <linux/stringify.h> | ||
| 8 | 9 | ||
| 9 | struct tvec_base; | 10 | struct tvec_base; |
| 10 | 11 | ||
| @@ -21,52 +22,126 @@ struct timer_list { | |||
| 21 | char start_comm[16]; | 22 | char start_comm[16]; |
| 22 | int start_pid; | 23 | int start_pid; |
| 23 | #endif | 24 | #endif |
| 25 | #ifdef CONFIG_LOCKDEP | ||
| 26 | struct lockdep_map lockdep_map; | ||
| 27 | #endif | ||
| 24 | }; | 28 | }; |
| 25 | 29 | ||
| 26 | extern struct tvec_base boot_tvec_bases; | 30 | extern struct tvec_base boot_tvec_bases; |
| 27 | 31 | ||
| 32 | #ifdef CONFIG_LOCKDEP | ||
| 33 | /* | ||
| 34 | * NB: because we have to copy the lockdep_map, setting the lockdep_map key | ||
| 35 | * (second argument) here is required, otherwise it could be initialised to | ||
| 36 | * the copy of the lockdep_map later! We use the pointer to and the string | ||
| 37 | * "<file>:<line>" as the key resp. the name of the lockdep_map. | ||
| 38 | */ | ||
| 39 | #define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn) \ | ||
| 40 | .lockdep_map = STATIC_LOCKDEP_MAP_INIT(_kn, &_kn), | ||
| 41 | #else | ||
| 42 | #define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn) | ||
| 43 | #endif | ||
| 44 | |||
| 28 | #define TIMER_INITIALIZER(_function, _expires, _data) { \ | 45 | #define TIMER_INITIALIZER(_function, _expires, _data) { \ |
| 29 | .entry = { .prev = TIMER_ENTRY_STATIC }, \ | 46 | .entry = { .prev = TIMER_ENTRY_STATIC }, \ |
| 30 | .function = (_function), \ | 47 | .function = (_function), \ |
| 31 | .expires = (_expires), \ | 48 | .expires = (_expires), \ |
| 32 | .data = (_data), \ | 49 | .data = (_data), \ |
| 33 | .base = &boot_tvec_bases, \ | 50 | .base = &boot_tvec_bases, \ |
| 51 | __TIMER_LOCKDEP_MAP_INITIALIZER( \ | ||
| 52 | __FILE__ ":" __stringify(__LINE__)) \ | ||
| 34 | } | 53 | } |
| 35 | 54 | ||
| 36 | #define DEFINE_TIMER(_name, _function, _expires, _data) \ | 55 | #define DEFINE_TIMER(_name, _function, _expires, _data) \ |
| 37 | struct timer_list _name = \ | 56 | struct timer_list _name = \ |
| 38 | TIMER_INITIALIZER(_function, _expires, _data) | 57 | TIMER_INITIALIZER(_function, _expires, _data) |
| 39 | 58 | ||
| 40 | void init_timer(struct timer_list *timer); | 59 | void init_timer_key(struct timer_list *timer, |
| 41 | void init_timer_deferrable(struct timer_list *timer); | 60 | const char *name, |
| 61 | struct lock_class_key *key); | ||
| 62 | void init_timer_deferrable_key(struct timer_list *timer, | ||
| 63 | const char *name, | ||
| 64 | struct lock_class_key *key); | ||
| 65 | |||
| 66 | #ifdef CONFIG_LOCKDEP | ||
| 67 | #define init_timer(timer) \ | ||
| 68 | do { \ | ||
| 69 | static struct lock_class_key __key; \ | ||
| 70 | init_timer_key((timer), #timer, &__key); \ | ||
| 71 | } while (0) | ||
| 72 | |||
| 73 | #define init_timer_deferrable(timer) \ | ||
| 74 | do { \ | ||
| 75 | static struct lock_class_key __key; \ | ||
| 76 | init_timer_deferrable_key((timer), #timer, &__key); \ | ||
| 77 | } while (0) | ||
| 78 | |||
| 79 | #define init_timer_on_stack(timer) \ | ||
| 80 | do { \ | ||
| 81 | static struct lock_class_key __key; \ | ||
| 82 | init_timer_on_stack_key((timer), #timer, &__key); \ | ||
| 83 | } while (0) | ||
| 84 | |||
| 85 | #define setup_timer(timer, fn, data) \ | ||
| 86 | do { \ | ||
| 87 | static struct lock_class_key __key; \ | ||
| 88 | setup_timer_key((timer), #timer, &__key, (fn), (data));\ | ||
| 89 | } while (0) | ||
| 90 | |||
| 91 | #define setup_timer_on_stack(timer, fn, data) \ | ||
| 92 | do { \ | ||
| 93 | static struct lock_class_key __key; \ | ||
| 94 | setup_timer_on_stack_key((timer), #timer, &__key, \ | ||
| 95 | (fn), (data)); \ | ||
| 96 | } while (0) | ||
| 97 | #else | ||
| 98 | #define init_timer(timer)\ | ||
| 99 | init_timer_key((timer), NULL, NULL) | ||
| 100 | #define init_timer_deferrable(timer)\ | ||
| 101 | init_timer_deferrable_key((timer), NULL, NULL) | ||
| 102 | #define init_timer_on_stack(timer)\ | ||
| 103 | init_timer_on_stack_key((timer), NULL, NULL) | ||
| 104 | #define setup_timer(timer, fn, data)\ | ||
| 105 | setup_timer_key((timer), NULL, NULL, (fn), (data)) | ||
| 106 | #define setup_timer_on_stack(timer, fn, data)\ | ||
| 107 | setup_timer_on_stack_key((timer), NULL, NULL, (fn), (data)) | ||
| 108 | #endif | ||
| 42 | 109 | ||
| 43 | #ifdef CONFIG_DEBUG_OBJECTS_TIMERS | 110 | #ifdef CONFIG_DEBUG_OBJECTS_TIMERS |
| 44 | extern void init_timer_on_stack(struct timer_list *timer); | 111 | extern void init_timer_on_stack_key(struct timer_list *timer, |
| 112 | const char *name, | ||
| 113 | struct lock_class_key *key); | ||
| 45 | extern void destroy_timer_on_stack(struct timer_list *timer); | 114 | extern void destroy_timer_on_stack(struct timer_list *timer); |
| 46 | #else | 115 | #else |
| 47 | static inline void destroy_timer_on_stack(struct timer_list *timer) { } | 116 | static inline void destroy_timer_on_stack(struct timer_list *timer) { } |
| 48 | static inline void init_timer_on_stack(struct timer_list *timer) | 117 | static inline void init_timer_on_stack_key(struct timer_list *timer, |
| 118 | const char *name, | ||
| 119 | struct lock_class_key *key) | ||
| 49 | { | 120 | { |
| 50 | init_timer(timer); | 121 | init_timer_key(timer, name, key); |
| 51 | } | 122 | } |
| 52 | #endif | 123 | #endif |
| 53 | 124 | ||
| 54 | static inline void setup_timer(struct timer_list * timer, | 125 | static inline void setup_timer_key(struct timer_list * timer, |
| 126 | const char *name, | ||
| 127 | struct lock_class_key *key, | ||
| 55 | void (*function)(unsigned long), | 128 | void (*function)(unsigned long), |
| 56 | unsigned long data) | 129 | unsigned long data) |
| 57 | { | 130 | { |
| 58 | timer->function = function; | 131 | timer->function = function; |
| 59 | timer->data = data; | 132 | timer->data = data; |
| 60 | init_timer(timer); | 133 | init_timer_key(timer, name, key); |
| 61 | } | 134 | } |
| 62 | 135 | ||
| 63 | static inline void setup_timer_on_stack(struct timer_list *timer, | 136 | static inline void setup_timer_on_stack_key(struct timer_list *timer, |
| 137 | const char *name, | ||
| 138 | struct lock_class_key *key, | ||
| 64 | void (*function)(unsigned long), | 139 | void (*function)(unsigned long), |
| 65 | unsigned long data) | 140 | unsigned long data) |
| 66 | { | 141 | { |
| 67 | timer->function = function; | 142 | timer->function = function; |
| 68 | timer->data = data; | 143 | timer->data = data; |
| 69 | init_timer_on_stack(timer); | 144 | init_timer_on_stack_key(timer, name, key); |
| 70 | } | 145 | } |
| 71 | 146 | ||
| 72 | /** | 147 | /** |
