diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-01 13:27:18 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-01 13:27:18 -0400 |
| commit | 627312b9a877983f2164a67d042541ec1ffc435b (patch) | |
| tree | a8109ce649b4ef26998254088a54b01acd3df73f | |
| parent | 94095a1fff89dffe9451839deae4c6a40cf3ec21 (diff) | |
| parent | 4fe84fb8c6b5081f7364af63aee8e118a665b966 (diff) | |
Merge branch 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull core locking changes from Ingo Molnar:
"It includes a lockdep improvement plus a spinlock inlining Kconfig
cleanup."
* 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
locking: Adjust spin lock inlining Kconfig options
lockdep: Check if nested lock is actually held
| -rw-r--r-- | kernel/Kconfig.locks | 103 | ||||
| -rw-r--r-- | kernel/lockdep.c | 39 |
2 files changed, 102 insertions, 40 deletions
diff --git a/kernel/Kconfig.locks b/kernel/Kconfig.locks index 2251882daf53..44511d100eaa 100644 --- a/kernel/Kconfig.locks +++ b/kernel/Kconfig.locks | |||
| @@ -87,6 +87,9 @@ config ARCH_INLINE_WRITE_UNLOCK_IRQ | |||
| 87 | config ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE | 87 | config ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE |
| 88 | bool | 88 | bool |
| 89 | 89 | ||
| 90 | config UNINLINE_SPIN_UNLOCK | ||
| 91 | bool | ||
| 92 | |||
| 90 | # | 93 | # |
| 91 | # lock_* functions are inlined when: | 94 | # lock_* functions are inlined when: |
| 92 | # - DEBUG_SPINLOCK=n and GENERIC_LOCKBREAK=n and ARCH_INLINE_*LOCK=y | 95 | # - DEBUG_SPINLOCK=n and GENERIC_LOCKBREAK=n and ARCH_INLINE_*LOCK=y |
| @@ -103,100 +106,120 @@ config ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE | |||
| 103 | # - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y | 106 | # - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y |
| 104 | # | 107 | # |
| 105 | 108 | ||
| 109 | if !DEBUG_SPINLOCK | ||
| 110 | |||
| 106 | config INLINE_SPIN_TRYLOCK | 111 | config INLINE_SPIN_TRYLOCK |
| 107 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_TRYLOCK | 112 | def_bool y |
| 113 | depends on ARCH_INLINE_SPIN_TRYLOCK | ||
| 108 | 114 | ||
| 109 | config INLINE_SPIN_TRYLOCK_BH | 115 | config INLINE_SPIN_TRYLOCK_BH |
| 110 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_TRYLOCK_BH | 116 | def_bool y |
| 117 | depends on ARCH_INLINE_SPIN_TRYLOCK_BH | ||
| 111 | 118 | ||
| 112 | config INLINE_SPIN_LOCK | 119 | config INLINE_SPIN_LOCK |
| 113 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK | 120 | def_bool y |
| 121 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK | ||
| 114 | 122 | ||
| 115 | config INLINE_SPIN_LOCK_BH | 123 | config INLINE_SPIN_LOCK_BH |
| 116 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 124 | def_bool y |
| 117 | ARCH_INLINE_SPIN_LOCK_BH | 125 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK_BH |
| 118 | 126 | ||
| 119 | config INLINE_SPIN_LOCK_IRQ | 127 | config INLINE_SPIN_LOCK_IRQ |
| 120 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 128 | def_bool y |
| 121 | ARCH_INLINE_SPIN_LOCK_IRQ | 129 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK_IRQ |
| 122 | 130 | ||
| 123 | config INLINE_SPIN_LOCK_IRQSAVE | 131 | config INLINE_SPIN_LOCK_IRQSAVE |
| 124 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 132 | def_bool y |
| 125 | ARCH_INLINE_SPIN_LOCK_IRQSAVE | 133 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK_IRQSAVE |
| 126 | |||
| 127 | config UNINLINE_SPIN_UNLOCK | ||
| 128 | bool | ||
| 129 | 134 | ||
| 130 | config INLINE_SPIN_UNLOCK_BH | 135 | config INLINE_SPIN_UNLOCK_BH |
| 131 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_UNLOCK_BH | 136 | def_bool y |
| 137 | depends on ARCH_INLINE_SPIN_UNLOCK_BH | ||
| 132 | 138 | ||
| 133 | config INLINE_SPIN_UNLOCK_IRQ | 139 | config INLINE_SPIN_UNLOCK_IRQ |
| 134 | def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_SPIN_UNLOCK_BH) | 140 | def_bool y |
| 141 | depends on !PREEMPT || ARCH_INLINE_SPIN_UNLOCK_BH | ||
| 135 | 142 | ||
| 136 | config INLINE_SPIN_UNLOCK_IRQRESTORE | 143 | config INLINE_SPIN_UNLOCK_IRQRESTORE |
| 137 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE | 144 | def_bool y |
| 145 | depends on ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE | ||
| 138 | 146 | ||
| 139 | 147 | ||
| 140 | config INLINE_READ_TRYLOCK | 148 | config INLINE_READ_TRYLOCK |
| 141 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_TRYLOCK | 149 | def_bool y |
| 150 | depends on ARCH_INLINE_READ_TRYLOCK | ||
| 142 | 151 | ||
| 143 | config INLINE_READ_LOCK | 152 | config INLINE_READ_LOCK |
| 144 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK | 153 | def_bool y |
| 154 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK | ||
| 145 | 155 | ||
| 146 | config INLINE_READ_LOCK_BH | 156 | config INLINE_READ_LOCK_BH |
| 147 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 157 | def_bool y |
| 148 | ARCH_INLINE_READ_LOCK_BH | 158 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK_BH |
| 149 | 159 | ||
| 150 | config INLINE_READ_LOCK_IRQ | 160 | config INLINE_READ_LOCK_IRQ |
| 151 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 161 | def_bool y |
| 152 | ARCH_INLINE_READ_LOCK_IRQ | 162 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK_IRQ |
| 153 | 163 | ||
| 154 | config INLINE_READ_LOCK_IRQSAVE | 164 | config INLINE_READ_LOCK_IRQSAVE |
| 155 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 165 | def_bool y |
| 156 | ARCH_INLINE_READ_LOCK_IRQSAVE | 166 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK_IRQSAVE |
| 157 | 167 | ||
| 158 | config INLINE_READ_UNLOCK | 168 | config INLINE_READ_UNLOCK |
| 159 | def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_READ_UNLOCK) | 169 | def_bool y |
| 170 | depends on !PREEMPT || ARCH_INLINE_READ_UNLOCK | ||
| 160 | 171 | ||
| 161 | config INLINE_READ_UNLOCK_BH | 172 | config INLINE_READ_UNLOCK_BH |
| 162 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_UNLOCK_BH | 173 | def_bool y |
| 174 | depends on ARCH_INLINE_READ_UNLOCK_BH | ||
| 163 | 175 | ||
| 164 | config INLINE_READ_UNLOCK_IRQ | 176 | config INLINE_READ_UNLOCK_IRQ |
| 165 | def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_READ_UNLOCK_BH) | 177 | def_bool y |
| 178 | depends on !PREEMPT || ARCH_INLINE_READ_UNLOCK_BH | ||
| 166 | 179 | ||
| 167 | config INLINE_READ_UNLOCK_IRQRESTORE | 180 | config INLINE_READ_UNLOCK_IRQRESTORE |
| 168 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_UNLOCK_IRQRESTORE | 181 | def_bool y |
| 182 | depends on ARCH_INLINE_READ_UNLOCK_IRQRESTORE | ||
| 169 | 183 | ||
| 170 | 184 | ||
| 171 | config INLINE_WRITE_TRYLOCK | 185 | config INLINE_WRITE_TRYLOCK |
| 172 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_TRYLOCK | 186 | def_bool y |
| 187 | depends on ARCH_INLINE_WRITE_TRYLOCK | ||
| 173 | 188 | ||
| 174 | config INLINE_WRITE_LOCK | 189 | config INLINE_WRITE_LOCK |
| 175 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_WRITE_LOCK | 190 | def_bool y |
| 191 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_WRITE_LOCK | ||
| 176 | 192 | ||
| 177 | config INLINE_WRITE_LOCK_BH | 193 | config INLINE_WRITE_LOCK_BH |
| 178 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 194 | def_bool y |
| 179 | ARCH_INLINE_WRITE_LOCK_BH | 195 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_WRITE_LOCK_BH |
| 180 | 196 | ||
| 181 | config INLINE_WRITE_LOCK_IRQ | 197 | config INLINE_WRITE_LOCK_IRQ |
| 182 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 198 | def_bool y |
| 183 | ARCH_INLINE_WRITE_LOCK_IRQ | 199 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_WRITE_LOCK_IRQ |
| 184 | 200 | ||
| 185 | config INLINE_WRITE_LOCK_IRQSAVE | 201 | config INLINE_WRITE_LOCK_IRQSAVE |
| 186 | def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \ | 202 | def_bool y |
| 187 | ARCH_INLINE_WRITE_LOCK_IRQSAVE | 203 | depends on !GENERIC_LOCKBREAK && ARCH_INLINE_WRITE_LOCK_IRQSAVE |
| 188 | 204 | ||
| 189 | config INLINE_WRITE_UNLOCK | 205 | config INLINE_WRITE_UNLOCK |
| 190 | def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_WRITE_UNLOCK) | 206 | def_bool y |
| 207 | depends on !PREEMPT || ARCH_INLINE_WRITE_UNLOCK | ||
| 191 | 208 | ||
| 192 | config INLINE_WRITE_UNLOCK_BH | 209 | config INLINE_WRITE_UNLOCK_BH |
| 193 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_UNLOCK_BH | 210 | def_bool y |
| 211 | depends on ARCH_INLINE_WRITE_UNLOCK_BH | ||
| 194 | 212 | ||
| 195 | config INLINE_WRITE_UNLOCK_IRQ | 213 | config INLINE_WRITE_UNLOCK_IRQ |
| 196 | def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_WRITE_UNLOCK_BH) | 214 | def_bool y |
| 215 | depends on !PREEMPT || ARCH_INLINE_WRITE_UNLOCK_BH | ||
| 197 | 216 | ||
| 198 | config INLINE_WRITE_UNLOCK_IRQRESTORE | 217 | config INLINE_WRITE_UNLOCK_IRQRESTORE |
| 199 | def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE | 218 | def_bool y |
| 219 | depends on ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE | ||
| 220 | |||
| 221 | endif | ||
| 200 | 222 | ||
| 201 | config MUTEX_SPIN_ON_OWNER | 223 | config MUTEX_SPIN_ON_OWNER |
| 202 | def_bool SMP && !DEBUG_MUTEXES | 224 | def_bool y |
| 225 | depends on SMP && !DEBUG_MUTEXES | ||
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index ea9ee4518c35..7981e5b2350d 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
| @@ -2998,6 +2998,42 @@ EXPORT_SYMBOL_GPL(lockdep_init_map); | |||
| 2998 | 2998 | ||
| 2999 | struct lock_class_key __lockdep_no_validate__; | 2999 | struct lock_class_key __lockdep_no_validate__; |
| 3000 | 3000 | ||
| 3001 | static int | ||
| 3002 | print_lock_nested_lock_not_held(struct task_struct *curr, | ||
| 3003 | struct held_lock *hlock, | ||
| 3004 | unsigned long ip) | ||
| 3005 | { | ||
| 3006 | if (!debug_locks_off()) | ||
| 3007 | return 0; | ||
| 3008 | if (debug_locks_silent) | ||
| 3009 | return 0; | ||
| 3010 | |||
| 3011 | printk("\n"); | ||
| 3012 | printk("==================================\n"); | ||
| 3013 | printk("[ BUG: Nested lock was not taken ]\n"); | ||
| 3014 | print_kernel_ident(); | ||
| 3015 | printk("----------------------------------\n"); | ||
| 3016 | |||
| 3017 | printk("%s/%d is trying to lock:\n", curr->comm, task_pid_nr(curr)); | ||
| 3018 | print_lock(hlock); | ||
| 3019 | |||
| 3020 | printk("\nbut this task is not holding:\n"); | ||
| 3021 | printk("%s\n", hlock->nest_lock->name); | ||
| 3022 | |||
| 3023 | printk("\nstack backtrace:\n"); | ||
| 3024 | dump_stack(); | ||
| 3025 | |||
| 3026 | printk("\nother info that might help us debug this:\n"); | ||
| 3027 | lockdep_print_held_locks(curr); | ||
| 3028 | |||
| 3029 | printk("\nstack backtrace:\n"); | ||
| 3030 | dump_stack(); | ||
| 3031 | |||
| 3032 | return 0; | ||
| 3033 | } | ||
| 3034 | |||
| 3035 | static int __lock_is_held(struct lockdep_map *lock); | ||
| 3036 | |||
| 3001 | /* | 3037 | /* |
| 3002 | * This gets called for every mutex_lock*()/spin_lock*() operation. | 3038 | * This gets called for every mutex_lock*()/spin_lock*() operation. |
| 3003 | * We maintain the dependency maps and validate the locking attempt: | 3039 | * We maintain the dependency maps and validate the locking attempt: |
| @@ -3139,6 +3175,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, | |||
| 3139 | } | 3175 | } |
| 3140 | chain_key = iterate_chain_key(chain_key, id); | 3176 | chain_key = iterate_chain_key(chain_key, id); |
| 3141 | 3177 | ||
| 3178 | if (nest_lock && !__lock_is_held(nest_lock)) | ||
| 3179 | return print_lock_nested_lock_not_held(curr, hlock, ip); | ||
| 3180 | |||
| 3142 | if (!validate_chain(curr, lock, hlock, chain_head, chain_key)) | 3181 | if (!validate_chain(curr, lock, hlock, chain_head, chain_key)) |
| 3143 | return 0; | 3182 | return 0; |
| 3144 | 3183 | ||
