aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/lockdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/lockdep.c')
-rw-r--r--kernel/lockdep.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index ed38bbfc48a3..723bd9f92556 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2654,10 +2654,15 @@ static void check_flags(unsigned long flags)
2654 if (!debug_locks) 2654 if (!debug_locks)
2655 return; 2655 return;
2656 2656
2657 if (irqs_disabled_flags(flags)) 2657 if (irqs_disabled_flags(flags)) {
2658 DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled); 2658 if (DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled)) {
2659 else 2659 printk("possible reason: unannotated irqs-off.\n");
2660 DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled); 2660 }
2661 } else {
2662 if (DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled)) {
2663 printk("possible reason: unannotated irqs-on.\n");
2664 }
2665 }
2661 2666
2662 /* 2667 /*
2663 * We dont accurately track softirq state in e.g. 2668 * We dont accurately track softirq state in e.g.
@@ -3054,11 +3059,6 @@ void __init lockdep_info(void)
3054#endif 3059#endif
3055} 3060}
3056 3061
3057static inline int in_range(const void *start, const void *addr, const void *end)
3058{
3059 return addr >= start && addr <= end;
3060}
3061
3062static void 3062static void
3063print_freed_lock_bug(struct task_struct *curr, const void *mem_from, 3063print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
3064 const void *mem_to, struct held_lock *hlock) 3064 const void *mem_to, struct held_lock *hlock)
@@ -3080,6 +3080,13 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
3080 dump_stack(); 3080 dump_stack();
3081} 3081}
3082 3082
3083static inline int not_in_range(const void* mem_from, unsigned long mem_len,
3084 const void* lock_from, unsigned long lock_len)
3085{
3086 return lock_from + lock_len <= mem_from ||
3087 mem_from + mem_len <= lock_from;
3088}
3089
3083/* 3090/*
3084 * Called when kernel memory is freed (or unmapped), or if a lock 3091 * Called when kernel memory is freed (or unmapped), or if a lock
3085 * is destroyed or reinitialized - this code checks whether there is 3092 * is destroyed or reinitialized - this code checks whether there is
@@ -3087,7 +3094,6 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
3087 */ 3094 */
3088void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len) 3095void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
3089{ 3096{
3090 const void *mem_to = mem_from + mem_len, *lock_from, *lock_to;
3091 struct task_struct *curr = current; 3097 struct task_struct *curr = current;
3092 struct held_lock *hlock; 3098 struct held_lock *hlock;
3093 unsigned long flags; 3099 unsigned long flags;
@@ -3100,14 +3106,11 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
3100 for (i = 0; i < curr->lockdep_depth; i++) { 3106 for (i = 0; i < curr->lockdep_depth; i++) {
3101 hlock = curr->held_locks + i; 3107 hlock = curr->held_locks + i;
3102 3108
3103 lock_from = (void *)hlock->instance; 3109 if (not_in_range(mem_from, mem_len, hlock->instance,
3104 lock_to = (void *)(hlock->instance + 1); 3110 sizeof(*hlock->instance)))
3105
3106 if (!in_range(mem_from, lock_from, mem_to) &&
3107 !in_range(mem_from, lock_to, mem_to))
3108 continue; 3111 continue;
3109 3112
3110 print_freed_lock_bug(curr, mem_from, mem_to, hlock); 3113 print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock);
3111 break; 3114 break;
3112 } 3115 }
3113 local_irq_restore(flags); 3116 local_irq_restore(flags);
@@ -3173,6 +3176,13 @@ retry:
3173 printk(" locked it.\n"); 3176 printk(" locked it.\n");
3174 3177
3175 do_each_thread(g, p) { 3178 do_each_thread(g, p) {
3179 /*
3180 * It's not reliable to print a task's held locks
3181 * if it's not sleeping (or if it's not the current
3182 * task):
3183 */
3184 if (p->state == TASK_RUNNING && p != current)
3185 continue;
3176 if (p->lockdep_depth) 3186 if (p->lockdep_depth)
3177 lockdep_print_held_locks(p); 3187 lockdep_print_held_locks(p);
3178 if (!unlock) 3188 if (!unlock)