aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/wait.h4
-rw-r--r--init/main.c3
-rw-r--r--kernel/lockdep.c31
-rw-r--r--kernel/panic.c17
-rw-r--r--kernel/rtmutex-debug.c1
-rw-r--r--kernel/wait.c4
6 files changed, 40 insertions, 20 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 3efc9f3f43a0..a9ce45e8501c 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -77,13 +77,13 @@ struct task_struct;
77#define __WAIT_BIT_KEY_INITIALIZER(word, bit) \ 77#define __WAIT_BIT_KEY_INITIALIZER(word, bit) \
78 { .flags = word, .bit_nr = bit, } 78 { .flags = word, .bit_nr = bit, }
79 79
80extern void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *); 80extern void __init_waitqueue_head(wait_queue_head_t *q, const char *name, struct lock_class_key *);
81 81
82#define init_waitqueue_head(q) \ 82#define init_waitqueue_head(q) \
83 do { \ 83 do { \
84 static struct lock_class_key __key; \ 84 static struct lock_class_key __key; \
85 \ 85 \
86 __init_waitqueue_head((q), &__key); \ 86 __init_waitqueue_head((q), #q, &__key); \
87 } while (0) 87 } while (0)
88 88
89#ifdef CONFIG_LOCKDEP 89#ifdef CONFIG_LOCKDEP
diff --git a/init/main.c b/init/main.c
index 217ed23e9487..2c76efb513c2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -469,13 +469,12 @@ asmlinkage void __init start_kernel(void)
469 char * command_line; 469 char * command_line;
470 extern const struct kernel_param __start___param[], __stop___param[]; 470 extern const struct kernel_param __start___param[], __stop___param[];
471 471
472 smp_setup_processor_id();
473
474 /* 472 /*
475 * Need to run as early as possible, to initialize the 473 * Need to run as early as possible, to initialize the
476 * lockdep hash: 474 * lockdep hash:
477 */ 475 */
478 lockdep_init(); 476 lockdep_init();
477 smp_setup_processor_id();
479 debug_objects_early_init(); 478 debug_objects_early_init();
480 479
481 /* 480 /*
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index b2e08c932d91..e69d633d6aa6 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -431,6 +431,7 @@ unsigned int max_lockdep_depth;
431 * about it later on, in lockdep_info(). 431 * about it later on, in lockdep_info().
432 */ 432 */
433static int lockdep_init_error; 433static int lockdep_init_error;
434static const char *lock_init_error;
434static unsigned long lockdep_init_trace_data[20]; 435static unsigned long lockdep_init_trace_data[20];
435static struct stack_trace lockdep_init_trace = { 436static struct stack_trace lockdep_init_trace = {
436 .max_entries = ARRAY_SIZE(lockdep_init_trace_data), 437 .max_entries = ARRAY_SIZE(lockdep_init_trace_data),
@@ -568,11 +569,12 @@ static void lockdep_print_held_locks(struct task_struct *curr)
568 } 569 }
569} 570}
570 571
571static void print_kernel_version(void) 572static void print_kernel_ident(void)
572{ 573{
573 printk("%s %.*s\n", init_utsname()->release, 574 printk("%s %.*s %s\n", init_utsname()->release,
574 (int)strcspn(init_utsname()->version, " "), 575 (int)strcspn(init_utsname()->version, " "),
575 init_utsname()->version); 576 init_utsname()->version,
577 print_tainted());
576} 578}
577 579
578static int very_verbose(struct lock_class *class) 580static int very_verbose(struct lock_class *class)
@@ -656,6 +658,7 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
656 if (unlikely(!lockdep_initialized)) { 658 if (unlikely(!lockdep_initialized)) {
657 lockdep_init(); 659 lockdep_init();
658 lockdep_init_error = 1; 660 lockdep_init_error = 1;
661 lock_init_error = lock->name;
659 save_stack_trace(&lockdep_init_trace); 662 save_stack_trace(&lockdep_init_trace);
660 } 663 }
661#endif 664#endif
@@ -723,7 +726,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
723 726
724 class = look_up_lock_class(lock, subclass); 727 class = look_up_lock_class(lock, subclass);
725 if (likely(class)) 728 if (likely(class))
726 return class; 729 goto out_set_class_cache;
727 730
728 /* 731 /*
729 * Debug-check: all keys must be persistent! 732 * Debug-check: all keys must be persistent!
@@ -808,6 +811,7 @@ out_unlock_set:
808 graph_unlock(); 811 graph_unlock();
809 raw_local_irq_restore(flags); 812 raw_local_irq_restore(flags);
810 813
814out_set_class_cache:
811 if (!subclass || force) 815 if (!subclass || force)
812 lock->class_cache[0] = class; 816 lock->class_cache[0] = class;
813 else if (subclass < NR_LOCKDEP_CACHING_CLASSES) 817 else if (subclass < NR_LOCKDEP_CACHING_CLASSES)
@@ -1149,7 +1153,7 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth,
1149 printk("\n"); 1153 printk("\n");
1150 printk("======================================================\n"); 1154 printk("======================================================\n");
1151 printk("[ INFO: possible circular locking dependency detected ]\n"); 1155 printk("[ INFO: possible circular locking dependency detected ]\n");
1152 print_kernel_version(); 1156 print_kernel_ident();
1153 printk("-------------------------------------------------------\n"); 1157 printk("-------------------------------------------------------\n");
1154 printk("%s/%d is trying to acquire lock:\n", 1158 printk("%s/%d is trying to acquire lock:\n",
1155 curr->comm, task_pid_nr(curr)); 1159 curr->comm, task_pid_nr(curr));
@@ -1488,7 +1492,7 @@ print_bad_irq_dependency(struct task_struct *curr,
1488 printk("======================================================\n"); 1492 printk("======================================================\n");
1489 printk("[ INFO: %s-safe -> %s-unsafe lock order detected ]\n", 1493 printk("[ INFO: %s-safe -> %s-unsafe lock order detected ]\n",
1490 irqclass, irqclass); 1494 irqclass, irqclass);
1491 print_kernel_version(); 1495 print_kernel_ident();
1492 printk("------------------------------------------------------\n"); 1496 printk("------------------------------------------------------\n");
1493 printk("%s/%d [HC%u[%lu]:SC%u[%lu]:HE%u:SE%u] is trying to acquire:\n", 1497 printk("%s/%d [HC%u[%lu]:SC%u[%lu]:HE%u:SE%u] is trying to acquire:\n",
1494 curr->comm, task_pid_nr(curr), 1498 curr->comm, task_pid_nr(curr),
@@ -1717,7 +1721,7 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
1717 printk("\n"); 1721 printk("\n");
1718 printk("=============================================\n"); 1722 printk("=============================================\n");
1719 printk("[ INFO: possible recursive locking detected ]\n"); 1723 printk("[ INFO: possible recursive locking detected ]\n");
1720 print_kernel_version(); 1724 print_kernel_ident();
1721 printk("---------------------------------------------\n"); 1725 printk("---------------------------------------------\n");
1722 printk("%s/%d is trying to acquire lock:\n", 1726 printk("%s/%d is trying to acquire lock:\n",
1723 curr->comm, task_pid_nr(curr)); 1727 curr->comm, task_pid_nr(curr));
@@ -2224,7 +2228,7 @@ print_usage_bug(struct task_struct *curr, struct held_lock *this,
2224 printk("\n"); 2228 printk("\n");
2225 printk("=================================\n"); 2229 printk("=================================\n");
2226 printk("[ INFO: inconsistent lock state ]\n"); 2230 printk("[ INFO: inconsistent lock state ]\n");
2227 print_kernel_version(); 2231 print_kernel_ident();
2228 printk("---------------------------------\n"); 2232 printk("---------------------------------\n");
2229 2233
2230 printk("inconsistent {%s} -> {%s} usage.\n", 2234 printk("inconsistent {%s} -> {%s} usage.\n",
@@ -2289,7 +2293,7 @@ print_irq_inversion_bug(struct task_struct *curr,
2289 printk("\n"); 2293 printk("\n");
2290 printk("=========================================================\n"); 2294 printk("=========================================================\n");
2291 printk("[ INFO: possible irq lock inversion dependency detected ]\n"); 2295 printk("[ INFO: possible irq lock inversion dependency detected ]\n");
2292 print_kernel_version(); 2296 print_kernel_ident();
2293 printk("---------------------------------------------------------\n"); 2297 printk("---------------------------------------------------------\n");
2294 printk("%s/%d just changed the state of lock:\n", 2298 printk("%s/%d just changed the state of lock:\n",
2295 curr->comm, task_pid_nr(curr)); 2299 curr->comm, task_pid_nr(curr));
@@ -3175,6 +3179,7 @@ print_unlock_inbalance_bug(struct task_struct *curr, struct lockdep_map *lock,
3175 printk("\n"); 3179 printk("\n");
3176 printk("=====================================\n"); 3180 printk("=====================================\n");
3177 printk("[ BUG: bad unlock balance detected! ]\n"); 3181 printk("[ BUG: bad unlock balance detected! ]\n");
3182 print_kernel_ident();
3178 printk("-------------------------------------\n"); 3183 printk("-------------------------------------\n");
3179 printk("%s/%d is trying to release lock (", 3184 printk("%s/%d is trying to release lock (",
3180 curr->comm, task_pid_nr(curr)); 3185 curr->comm, task_pid_nr(curr));
@@ -3619,6 +3624,7 @@ print_lock_contention_bug(struct task_struct *curr, struct lockdep_map *lock,
3619 printk("\n"); 3624 printk("\n");
3620 printk("=================================\n"); 3625 printk("=================================\n");
3621 printk("[ BUG: bad contention detected! ]\n"); 3626 printk("[ BUG: bad contention detected! ]\n");
3627 print_kernel_ident();
3622 printk("---------------------------------\n"); 3628 printk("---------------------------------\n");
3623 printk("%s/%d is trying to contend lock (", 3629 printk("%s/%d is trying to contend lock (",
3624 curr->comm, task_pid_nr(curr)); 3630 curr->comm, task_pid_nr(curr));
@@ -3974,7 +3980,8 @@ void __init lockdep_info(void)
3974 3980
3975#ifdef CONFIG_DEBUG_LOCKDEP 3981#ifdef CONFIG_DEBUG_LOCKDEP
3976 if (lockdep_init_error) { 3982 if (lockdep_init_error) {
3977 printk("WARNING: lockdep init error! Arch code didn't call lockdep_init() early enough?\n"); 3983 printk("WARNING: lockdep init error! lock-%s was acquired"
3984 "before lockdep_init\n", lock_init_error);
3978 printk("Call stack leading to lockdep invocation was:\n"); 3985 printk("Call stack leading to lockdep invocation was:\n");
3979 print_stack_trace(&lockdep_init_trace, 0); 3986 print_stack_trace(&lockdep_init_trace, 0);
3980 } 3987 }
@@ -3993,6 +4000,7 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
3993 printk("\n"); 4000 printk("\n");
3994 printk("=========================\n"); 4001 printk("=========================\n");
3995 printk("[ BUG: held lock freed! ]\n"); 4002 printk("[ BUG: held lock freed! ]\n");
4003 print_kernel_ident();
3996 printk("-------------------------\n"); 4004 printk("-------------------------\n");
3997 printk("%s/%d is freeing memory %p-%p, with a lock still held there!\n", 4005 printk("%s/%d is freeing memory %p-%p, with a lock still held there!\n",
3998 curr->comm, task_pid_nr(curr), mem_from, mem_to-1); 4006 curr->comm, task_pid_nr(curr), mem_from, mem_to-1);
@@ -4050,6 +4058,7 @@ static void print_held_locks_bug(struct task_struct *curr)
4050 printk("\n"); 4058 printk("\n");
4051 printk("=====================================\n"); 4059 printk("=====================================\n");
4052 printk("[ BUG: lock held at task exit time! ]\n"); 4060 printk("[ BUG: lock held at task exit time! ]\n");
4061 print_kernel_ident();
4053 printk("-------------------------------------\n"); 4062 printk("-------------------------------------\n");
4054 printk("%s/%d is exiting with locks still held!\n", 4063 printk("%s/%d is exiting with locks still held!\n",
4055 curr->comm, task_pid_nr(curr)); 4064 curr->comm, task_pid_nr(curr));
@@ -4147,6 +4156,7 @@ void lockdep_sys_exit(void)
4147 printk("\n"); 4156 printk("\n");
4148 printk("================================================\n"); 4157 printk("================================================\n");
4149 printk("[ BUG: lock held when returning to user space! ]\n"); 4158 printk("[ BUG: lock held when returning to user space! ]\n");
4159 print_kernel_ident();
4150 printk("------------------------------------------------\n"); 4160 printk("------------------------------------------------\n");
4151 printk("%s/%d is leaving the kernel with locks still held!\n", 4161 printk("%s/%d is leaving the kernel with locks still held!\n",
4152 curr->comm, curr->pid); 4162 curr->comm, curr->pid);
@@ -4166,6 +4176,7 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
4166 printk("\n"); 4176 printk("\n");
4167 printk("===============================\n"); 4177 printk("===============================\n");
4168 printk("[ INFO: suspicious RCU usage. ]\n"); 4178 printk("[ INFO: suspicious RCU usage. ]\n");
4179 print_kernel_ident();
4169 printk("-------------------------------\n"); 4180 printk("-------------------------------\n");
4170 printk("%s:%d %s!\n", file, line, s); 4181 printk("%s:%d %s!\n", file, line, s);
4171 printk("\nother info that might help us debug this:\n\n"); 4182 printk("\nother info that might help us debug this:\n\n");
diff --git a/kernel/panic.c b/kernel/panic.c
index b26593604214..3458469eb7c3 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -237,11 +237,20 @@ void add_taint(unsigned flag)
237 * Can't trust the integrity of the kernel anymore. 237 * Can't trust the integrity of the kernel anymore.
238 * We don't call directly debug_locks_off() because the issue 238 * We don't call directly debug_locks_off() because the issue
239 * is not necessarily serious enough to set oops_in_progress to 1 239 * is not necessarily serious enough to set oops_in_progress to 1
240 * Also we want to keep up lockdep for staging development and 240 * Also we want to keep up lockdep for staging/out-of-tree
241 * post-warning case. 241 * development and post-warning case.
242 */ 242 */
243 if (flag != TAINT_CRAP && flag != TAINT_WARN && __debug_locks_off()) 243 switch (flag) {
244 printk(KERN_WARNING "Disabling lock debugging due to kernel taint\n"); 244 case TAINT_CRAP:
245 case TAINT_OOT_MODULE:
246 case TAINT_WARN:
247 case TAINT_FIRMWARE_WORKAROUND:
248 break;
249
250 default:
251 if (__debug_locks_off())
252 printk(KERN_WARNING "Disabling lock debugging due to kernel taint\n");
253 }
245 254
246 set_bit(flag, &tainted_mask); 255 set_bit(flag, &tainted_mask);
247} 256}
diff --git a/kernel/rtmutex-debug.c b/kernel/rtmutex-debug.c
index 8eafd1bd273e..16502d3a71c8 100644
--- a/kernel/rtmutex-debug.c
+++ b/kernel/rtmutex-debug.c
@@ -101,6 +101,7 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
101 101
102 printk("\n============================================\n"); 102 printk("\n============================================\n");
103 printk( "[ BUG: circular locking deadlock detected! ]\n"); 103 printk( "[ BUG: circular locking deadlock detected! ]\n");
104 printk("%s\n", print_tainted());
104 printk( "--------------------------------------------\n"); 105 printk( "--------------------------------------------\n");
105 printk("%s/%d is deadlocking current task %s/%d\n\n", 106 printk("%s/%d is deadlocking current task %s/%d\n\n",
106 task->comm, task_pid_nr(task), 107 task->comm, task_pid_nr(task),
diff --git a/kernel/wait.c b/kernel/wait.c
index 26fa7797f90f..7fdd9eaca2c3 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -10,10 +10,10 @@
10#include <linux/wait.h> 10#include <linux/wait.h>
11#include <linux/hash.h> 11#include <linux/hash.h>
12 12
13void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *key) 13void __init_waitqueue_head(wait_queue_head_t *q, const char *name, struct lock_class_key *key)
14{ 14{
15 spin_lock_init(&q->lock); 15 spin_lock_init(&q->lock);
16 lockdep_set_class(&q->lock, key); 16 lockdep_set_class_and_name(&q->lock, key, name);
17 INIT_LIST_HEAD(&q->task_list); 17 INIT_LIST_HEAD(&q->task_list);
18} 18}
19 19