Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Runtime locking correctness validator |
| 4 | * |
Peter Zijlstra | 4b32d0a | 2007-07-19 01:48:59 -0700 | [diff] [blame] | 5 | * Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> |
Peter Zijlstra | 90eec10 | 2015-11-16 11:08:45 +0100 | [diff] [blame] | 6 | * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 7 | * |
Mauro Carvalho Chehab | 387b146 | 2019-04-10 08:32:41 -0300 | [diff] [blame] | 8 | * see Documentation/locking/lockdep-design.rst for more details. |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 9 | */ |
| 10 | #ifndef __LINUX_LOCKDEP_H |
| 11 | #define __LINUX_LOCKDEP_H |
| 12 | |
Herbert Xu | c935cd6 | 2020-06-17 17:17:19 +1000 | [diff] [blame] | 13 | #include <linux/lockdep_types.h> |
Peter Zijlstra | a21ee60 | 2020-05-25 12:22:41 +0200 | [diff] [blame] | 14 | #include <asm/percpu.h> |
Herbert Xu | c935cd6 | 2020-06-17 17:17:19 +1000 | [diff] [blame] | 15 | |
Heiko Carstens | a1e96b0 | 2007-02-12 00:52:20 -0800 | [diff] [blame] | 16 | struct task_struct; |
| 17 | |
Dave Young | 2edf5e4 | 2010-03-10 15:24:10 -0800 | [diff] [blame] | 18 | /* for sysctl */ |
| 19 | extern int prove_locking; |
| 20 | extern int lock_stat; |
| 21 | |
Michael S. Tsirkin | db0b0ea | 2006-09-29 01:59:28 -0700 | [diff] [blame] | 22 | #ifdef CONFIG_LOCKDEP |
| 23 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 24 | #include <linux/linkage.h> |
Herbert Xu | 5be542e | 2020-07-16 16:36:50 +1000 | [diff] [blame] | 25 | #include <linux/list.h> |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 26 | #include <linux/debug_locks.h> |
| 27 | #include <linux/stacktrace.h> |
| 28 | |
Peter Zijlstra | 4d82a1d | 2012-05-15 08:06:19 -0700 | [diff] [blame] | 29 | static inline void lockdep_copy_map(struct lockdep_map *to, |
| 30 | struct lockdep_map *from) |
| 31 | { |
| 32 | int i; |
| 33 | |
| 34 | *to = *from; |
| 35 | /* |
| 36 | * Since the class cache can be modified concurrently we could observe |
| 37 | * half pointers (64bit arch using 32bit copy insns). Therefore clear |
| 38 | * the caches and take the performance hit. |
| 39 | * |
| 40 | * XXX it doesn't work well with lockdep_set_class_and_subclass(), since |
| 41 | * that relies on cache abuse. |
| 42 | */ |
| 43 | for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++) |
| 44 | to->class_cache[i] = NULL; |
| 45 | } |
| 46 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 47 | /* |
| 48 | * Every lock has a list of other locks that were taken after it. |
| 49 | * We only grow the list, never remove from it: |
| 50 | */ |
| 51 | struct lock_list { |
| 52 | struct list_head entry; |
| 53 | struct lock_class *class; |
Bart Van Assche | 86cffb8 | 2019-02-14 15:00:41 -0800 | [diff] [blame] | 54 | struct lock_class *links_to; |
Bart Van Assche | 12593b7 | 2019-07-22 11:24:42 -0700 | [diff] [blame] | 55 | const struct lock_trace *trace; |
Jason Baron | 068135e | 2007-02-10 01:44:59 -0800 | [diff] [blame] | 56 | int distance; |
Ming Lei | c94aa5c | 2009-07-16 15:44:29 +0200 | [diff] [blame] | 57 | |
Peter Zijlstra | af01296 | 2009-07-16 15:44:29 +0200 | [diff] [blame] | 58 | /* |
| 59 | * The parent field is used to implement breadth-first search, and the |
| 60 | * bit 0 is reused to indicate if the lock has been accessed in BFS. |
Ming Lei | c94aa5c | 2009-07-16 15:44:29 +0200 | [diff] [blame] | 61 | */ |
| 62 | struct lock_list *parent; |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
Yuyang Du | d16dbd1 | 2019-05-06 16:19:22 +0800 | [diff] [blame] | 65 | /** |
| 66 | * struct lock_chain - lock dependency chain record |
| 67 | * |
| 68 | * @irq_context: the same as irq_context in held_lock below |
| 69 | * @depth: the number of held locks in this chain |
| 70 | * @base: the index in chain_hlocks for this chain |
| 71 | * @entry: the collided lock chains in lock_chain hash list |
| 72 | * @chain_key: the hash key of this lock_chain |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 73 | */ |
| 74 | struct lock_chain { |
Yuyang Du | d16dbd1 | 2019-05-06 16:19:22 +0800 | [diff] [blame] | 75 | /* see BUILD_BUG_ON()s in add_chain_cache() */ |
Peter Zijlstra | 75dd602 | 2016-03-30 11:36:59 +0200 | [diff] [blame] | 76 | unsigned int irq_context : 2, |
| 77 | depth : 6, |
| 78 | base : 24; |
| 79 | /* 4 byte hole */ |
Andrew Morton | a63f38c | 2016-02-03 13:44:12 -0800 | [diff] [blame] | 80 | struct hlist_node entry; |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 81 | u64 chain_key; |
| 82 | }; |
| 83 | |
Ingo Molnar | e5f363e3 | 2008-08-11 12:37:27 +0200 | [diff] [blame] | 84 | #define MAX_LOCKDEP_KEYS_BITS 13 |
Yuyang Du | 01bb6f0 | 2019-05-06 16:19:25 +0800 | [diff] [blame] | 85 | #define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS) |
| 86 | #define INITIAL_CHAIN_KEY -1 |
Dave Jones | f82b217 | 2008-08-11 09:30:23 +0200 | [diff] [blame] | 87 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 88 | struct held_lock { |
| 89 | /* |
| 90 | * One-way hash of the dependency chain up to this point. We |
| 91 | * hash the hashes step by step as the dependency chain grows. |
| 92 | * |
| 93 | * We use it for dependency-caching and we skip detection |
| 94 | * passes and dependency-updates if there is a cache-hit, so |
| 95 | * it is absolutely critical for 100% coverage of the validator |
| 96 | * to have a unique key value for every unique dependency path |
| 97 | * that can occur in the system, to make a unique hash value |
| 98 | * as likely as possible - hence the 64-bit width. |
| 99 | * |
| 100 | * The task struct holds the current hash value (initialized |
| 101 | * with zero), here we store the previous hash value: |
| 102 | */ |
| 103 | u64 prev_chain_key; |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 104 | unsigned long acquire_ip; |
| 105 | struct lockdep_map *instance; |
Peter Zijlstra | 7531e2f | 2008-08-11 09:30:24 +0200 | [diff] [blame] | 106 | struct lockdep_map *nest_lock; |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 107 | #ifdef CONFIG_LOCK_STAT |
| 108 | u64 waittime_stamp; |
| 109 | u64 holdtime_stamp; |
| 110 | #endif |
Yuyang Du | 01bb6f0 | 2019-05-06 16:19:25 +0800 | [diff] [blame] | 111 | /* |
| 112 | * class_idx is zero-indexed; it points to the element in |
| 113 | * lock_classes this held lock instance belongs to. class_idx is in |
| 114 | * the range from 0 to (MAX_LOCKDEP_KEYS-1) inclusive. |
| 115 | */ |
Dave Jones | f82b217 | 2008-08-11 09:30:23 +0200 | [diff] [blame] | 116 | unsigned int class_idx:MAX_LOCKDEP_KEYS_BITS; |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 117 | /* |
| 118 | * The lock-stack is unified in that the lock chains of interrupt |
| 119 | * contexts nest ontop of process context chains, but we 'separate' |
| 120 | * the hashes by starting with 0 if we cross into an interrupt |
| 121 | * context, and we also keep do not add cross-context lock |
| 122 | * dependencies - the lock usage graph walking covers that area |
| 123 | * anyway, and we'd just unnecessarily increase the number of |
| 124 | * dependencies otherwise. [Note: hardirq and softirq contexts |
| 125 | * are separated from each other too.] |
| 126 | * |
| 127 | * The following field is used to detect when we cross into an |
| 128 | * interrupt context: |
| 129 | */ |
Dave Jones | f82b217 | 2008-08-11 09:30:23 +0200 | [diff] [blame] | 130 | unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */ |
Peter Zijlstra | bb97a91 | 2009-07-20 19:15:35 +0200 | [diff] [blame] | 131 | unsigned int trylock:1; /* 16 bits */ |
| 132 | |
Dave Jones | f82b217 | 2008-08-11 09:30:23 +0200 | [diff] [blame] | 133 | unsigned int read:2; /* see lock_acquire() comment */ |
Oleg Nesterov | fb9edbe | 2014-01-20 19:20:06 +0100 | [diff] [blame] | 134 | unsigned int check:1; /* see lock_acquire() comment */ |
Dave Jones | f82b217 | 2008-08-11 09:30:23 +0200 | [diff] [blame] | 135 | unsigned int hardirqs_off:1; |
Oleg Nesterov | fb9edbe | 2014-01-20 19:20:06 +0100 | [diff] [blame] | 136 | unsigned int references:12; /* 32 bits */ |
Peter Zijlstra | a24fc60 | 2015-06-11 14:46:53 +0200 | [diff] [blame] | 137 | unsigned int pin_count; |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | /* |
| 141 | * Initialization, self-test and debugging-output methods: |
| 142 | */ |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 143 | extern void lockdep_init(void); |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 144 | extern void lockdep_reset(void); |
| 145 | extern void lockdep_reset_lock(struct lockdep_map *lock); |
| 146 | extern void lockdep_free_key_range(void *start, unsigned long size); |
Andi Kleen | 63f9a7f | 2014-02-08 08:52:01 +0100 | [diff] [blame] | 147 | extern asmlinkage void lockdep_sys_exit(void); |
Bart Van Assche | cdc84d7 | 2019-02-14 15:00:44 -0800 | [diff] [blame] | 148 | extern void lockdep_set_selftest_task(struct task_struct *task); |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 149 | |
Yuyang Du | e196e47 | 2019-05-06 16:19:23 +0800 | [diff] [blame] | 150 | extern void lockdep_init_task(struct task_struct *task); |
| 151 | |
Peter Zijlstra | e616cb8 | 2020-02-24 22:14:51 +0100 | [diff] [blame] | 152 | /* |
| 153 | * Split the recrursion counter in two to readily detect 'off' vs recursion. |
| 154 | */ |
| 155 | #define LOCKDEP_RECURSION_BITS 16 |
| 156 | #define LOCKDEP_OFF (1U << LOCKDEP_RECURSION_BITS) |
| 157 | #define LOCKDEP_RECURSION_MASK (LOCKDEP_OFF - 1) |
| 158 | |
| 159 | /* |
| 160 | * lockdep_{off,on}() are macros to avoid tracing and kprobes; not inlines due |
| 161 | * to header dependencies. |
| 162 | */ |
| 163 | |
| 164 | #define lockdep_off() \ |
| 165 | do { \ |
| 166 | current->lockdep_recursion += LOCKDEP_OFF; \ |
| 167 | } while (0) |
| 168 | |
| 169 | #define lockdep_on() \ |
| 170 | do { \ |
| 171 | current->lockdep_recursion -= LOCKDEP_OFF; \ |
| 172 | } while (0) |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 173 | |
Bart Van Assche | 108c148 | 2019-02-14 15:00:53 -0800 | [diff] [blame] | 174 | extern void lockdep_register_key(struct lock_class_key *key); |
| 175 | extern void lockdep_unregister_key(struct lock_class_key *key); |
| 176 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 177 | /* |
| 178 | * These methods are used by specific locking variants (spinlocks, |
| 179 | * rwlocks, mutexes and rwsems) to pass init/acquire/release events |
| 180 | * to lockdep: |
| 181 | */ |
| 182 | |
Peter Zijlstra | de8f5e4 | 2020-03-21 12:26:01 +0100 | [diff] [blame] | 183 | extern void lockdep_init_map_waits(struct lockdep_map *lock, const char *name, |
| 184 | struct lock_class_key *key, int subclass, short inner, short outer); |
| 185 | |
| 186 | static inline void |
| 187 | lockdep_init_map_wait(struct lockdep_map *lock, const char *name, |
| 188 | struct lock_class_key *key, int subclass, short inner) |
| 189 | { |
| 190 | lockdep_init_map_waits(lock, name, key, subclass, inner, LD_WAIT_INV); |
| 191 | } |
| 192 | |
| 193 | static inline void lockdep_init_map(struct lockdep_map *lock, const char *name, |
| 194 | struct lock_class_key *key, int subclass) |
| 195 | { |
| 196 | lockdep_init_map_wait(lock, name, key, subclass, LD_WAIT_INV); |
| 197 | } |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 198 | |
| 199 | /* |
| 200 | * Reinitialize a lock key - for cases where there is special locking or |
| 201 | * special initialization of locks so that the validator gets the scope |
| 202 | * of dependencies wrong: they are either too broad (they need a class-split) |
| 203 | * or they are too narrow (they suffer from a false class-split): |
| 204 | */ |
Peter Zijlstra | de8f5e4 | 2020-03-21 12:26:01 +0100 | [diff] [blame] | 205 | #define lockdep_set_class(lock, key) \ |
| 206 | lockdep_init_map_waits(&(lock)->dep_map, #key, key, 0, \ |
| 207 | (lock)->dep_map.wait_type_inner, \ |
| 208 | (lock)->dep_map.wait_type_outer) |
| 209 | |
| 210 | #define lockdep_set_class_and_name(lock, key, name) \ |
| 211 | lockdep_init_map_waits(&(lock)->dep_map, name, key, 0, \ |
| 212 | (lock)->dep_map.wait_type_inner, \ |
| 213 | (lock)->dep_map.wait_type_outer) |
| 214 | |
| 215 | #define lockdep_set_class_and_subclass(lock, key, sub) \ |
| 216 | lockdep_init_map_waits(&(lock)->dep_map, #key, key, sub,\ |
| 217 | (lock)->dep_map.wait_type_inner, \ |
| 218 | (lock)->dep_map.wait_type_outer) |
| 219 | |
| 220 | #define lockdep_set_subclass(lock, sub) \ |
| 221 | lockdep_init_map_waits(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\ |
| 222 | (lock)->dep_map.wait_type_inner, \ |
| 223 | (lock)->dep_map.wait_type_outer) |
Peter Zijlstra | 1704f47 | 2010-03-19 01:37:42 +0100 | [diff] [blame] | 224 | |
| 225 | #define lockdep_set_novalidate_class(lock) \ |
Oleg Nesterov | 47be1c1 | 2014-01-20 19:20:16 +0100 | [diff] [blame] | 226 | lockdep_set_class_and_name(lock, &__lockdep_no_validate__, #lock) |
Peter Zijlstra | de8f5e4 | 2020-03-21 12:26:01 +0100 | [diff] [blame] | 227 | |
Jan Kara | 9a7aa12 | 2009-06-04 15:26:49 +0200 | [diff] [blame] | 228 | /* |
| 229 | * Compare locking classes |
| 230 | */ |
| 231 | #define lockdep_match_class(lock, key) lockdep_match_key(&(lock)->dep_map, key) |
| 232 | |
| 233 | static inline int lockdep_match_key(struct lockdep_map *lock, |
| 234 | struct lock_class_key *key) |
| 235 | { |
| 236 | return lock->key == key; |
| 237 | } |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 238 | |
| 239 | /* |
| 240 | * Acquire a lock. |
| 241 | * |
| 242 | * Values for "read": |
| 243 | * |
| 244 | * 0: exclusive (write) acquire |
| 245 | * 1: read-acquire (no recursion allowed) |
| 246 | * 2: read-acquire with same-instance recursion allowed |
| 247 | * |
| 248 | * Values for check: |
| 249 | * |
Oleg Nesterov | fb9edbe | 2014-01-20 19:20:06 +0100 | [diff] [blame] | 250 | * 0: simple checks (freeing, held-at-exit-time, etc.) |
| 251 | * 1: full validation |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 252 | */ |
| 253 | extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass, |
Peter Zijlstra | 7531e2f | 2008-08-11 09:30:24 +0200 | [diff] [blame] | 254 | int trylock, int read, int check, |
| 255 | struct lockdep_map *nest_lock, unsigned long ip); |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 256 | |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 257 | extern void lock_release(struct lockdep_map *lock, unsigned long ip); |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 258 | |
Peter Zijlstra | f831948 | 2016-11-30 14:32:25 +1100 | [diff] [blame] | 259 | /* |
| 260 | * Same "read" as for lock_acquire(), except -1 means any. |
| 261 | */ |
Matthew Wilcox | 08f36ff | 2018-01-17 07:14:13 -0800 | [diff] [blame] | 262 | extern int lock_is_held_type(const struct lockdep_map *lock, int read); |
Peter Zijlstra | f607c66 | 2009-07-20 19:16:29 +0200 | [diff] [blame] | 263 | |
Matthew Wilcox | 08f36ff | 2018-01-17 07:14:13 -0800 | [diff] [blame] | 264 | static inline int lock_is_held(const struct lockdep_map *lock) |
Peter Zijlstra | f831948 | 2016-11-30 14:32:25 +1100 | [diff] [blame] | 265 | { |
| 266 | return lock_is_held_type(lock, -1); |
| 267 | } |
| 268 | |
| 269 | #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map) |
| 270 | #define lockdep_is_held_type(lock, r) lock_is_held_type(&(lock)->dep_map, (r)) |
Peter Zijlstra | f607c66 | 2009-07-20 19:16:29 +0200 | [diff] [blame] | 271 | |
Peter Zijlstra | 00ef9f7 | 2008-12-04 09:00:17 +0100 | [diff] [blame] | 272 | extern void lock_set_class(struct lockdep_map *lock, const char *name, |
| 273 | struct lock_class_key *key, unsigned int subclass, |
| 274 | unsigned long ip); |
| 275 | |
| 276 | static inline void lock_set_subclass(struct lockdep_map *lock, |
| 277 | unsigned int subclass, unsigned long ip) |
| 278 | { |
| 279 | lock_set_class(lock, lock->name, lock->key, subclass, ip); |
| 280 | } |
Peter Zijlstra | 64aa348 | 2008-08-11 09:30:21 +0200 | [diff] [blame] | 281 | |
J. R. Okajima | 6419c4a | 2017-02-03 01:38:17 +0900 | [diff] [blame] | 282 | extern void lock_downgrade(struct lockdep_map *lock, unsigned long ip); |
| 283 | |
Peter Zijlstra | e7904a2 | 2015-08-01 19:25:08 +0200 | [diff] [blame] | 284 | #define NIL_COOKIE (struct pin_cookie){ .val = 0U, } |
| 285 | |
| 286 | extern struct pin_cookie lock_pin_lock(struct lockdep_map *lock); |
| 287 | extern void lock_repin_lock(struct lockdep_map *lock, struct pin_cookie); |
| 288 | extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie); |
Peter Zijlstra | a24fc60 | 2015-06-11 14:46:53 +0200 | [diff] [blame] | 289 | |
Jarek Poplawski | e3a55fd | 2007-03-22 00:11:26 -0800 | [diff] [blame] | 290 | #define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0) |
Peter Zijlstra | d5abe66 | 2006-12-06 20:37:26 -0800 | [diff] [blame] | 291 | |
Johannes Berg | b1ae345 | 2013-02-21 16:42:47 -0800 | [diff] [blame] | 292 | #define lockdep_assert_held(l) do { \ |
| 293 | WARN_ON(debug_locks && !lockdep_is_held(l)); \ |
| 294 | } while (0) |
Peter Zijlstra | f607c66 | 2009-07-20 19:16:29 +0200 | [diff] [blame] | 295 | |
Nikolay Borisov | 9ffbe8a | 2019-05-31 13:06:51 +0300 | [diff] [blame] | 296 | #define lockdep_assert_held_write(l) do { \ |
Peter Zijlstra | f831948 | 2016-11-30 14:32:25 +1100 | [diff] [blame] | 297 | WARN_ON(debug_locks && !lockdep_is_held_type(l, 0)); \ |
| 298 | } while (0) |
| 299 | |
| 300 | #define lockdep_assert_held_read(l) do { \ |
| 301 | WARN_ON(debug_locks && !lockdep_is_held_type(l, 1)); \ |
| 302 | } while (0) |
| 303 | |
Peter Hurley | 9a37110 | 2014-09-10 14:31:39 -0400 | [diff] [blame] | 304 | #define lockdep_assert_held_once(l) do { \ |
| 305 | WARN_ON_ONCE(debug_locks && !lockdep_is_held(l)); \ |
| 306 | } while (0) |
| 307 | |
Peter Zijlstra | 94d24fc | 2011-06-07 11:17:30 +0200 | [diff] [blame] | 308 | #define lockdep_recursing(tsk) ((tsk)->lockdep_recursion) |
| 309 | |
Peter Zijlstra | e7904a2 | 2015-08-01 19:25:08 +0200 | [diff] [blame] | 310 | #define lockdep_pin_lock(l) lock_pin_lock(&(l)->dep_map) |
| 311 | #define lockdep_repin_lock(l,c) lock_repin_lock(&(l)->dep_map, (c)) |
| 312 | #define lockdep_unpin_lock(l,c) lock_unpin_lock(&(l)->dep_map, (c)) |
Peter Zijlstra | a24fc60 | 2015-06-11 14:46:53 +0200 | [diff] [blame] | 313 | |
Michel Lespinasse | a51805e | 2013-07-08 14:23:49 -0700 | [diff] [blame] | 314 | #else /* !CONFIG_LOCKDEP */ |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 315 | |
Yuyang Du | e196e47 | 2019-05-06 16:19:23 +0800 | [diff] [blame] | 316 | static inline void lockdep_init_task(struct task_struct *task) |
| 317 | { |
| 318 | } |
| 319 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 320 | static inline void lockdep_off(void) |
| 321 | { |
| 322 | } |
| 323 | |
| 324 | static inline void lockdep_on(void) |
| 325 | { |
| 326 | } |
| 327 | |
Bart Van Assche | cdc84d7 | 2019-02-14 15:00:44 -0800 | [diff] [blame] | 328 | static inline void lockdep_set_selftest_task(struct task_struct *task) |
| 329 | { |
| 330 | } |
| 331 | |
Peter Zijlstra | 7531e2f | 2008-08-11 09:30:24 +0200 | [diff] [blame] | 332 | # define lock_acquire(l, s, t, r, c, n, i) do { } while (0) |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 333 | # define lock_release(l, i) do { } while (0) |
J. R. Okajima | 6419c4a | 2017-02-03 01:38:17 +0900 | [diff] [blame] | 334 | # define lock_downgrade(l, i) do { } while (0) |
Peter Zijlstra | 00ef9f7 | 2008-12-04 09:00:17 +0100 | [diff] [blame] | 335 | # define lock_set_class(l, n, k, s, i) do { } while (0) |
Peter Zijlstra | 64aa348 | 2008-08-11 09:30:21 +0200 | [diff] [blame] | 336 | # define lock_set_subclass(l, s, i) do { } while (0) |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 337 | # define lockdep_init() do { } while (0) |
Peter Zijlstra | de8f5e4 | 2020-03-21 12:26:01 +0100 | [diff] [blame] | 338 | # define lockdep_init_map_waits(lock, name, key, sub, inner, outer) \ |
| 339 | do { (void)(name); (void)(key); } while (0) |
| 340 | # define lockdep_init_map_wait(lock, name, key, sub, inner) \ |
| 341 | do { (void)(name); (void)(key); } while (0) |
Ingo Molnar | e25cf3d | 2008-10-17 15:55:07 +0200 | [diff] [blame] | 342 | # define lockdep_init_map(lock, name, key, sub) \ |
| 343 | do { (void)(name); (void)(key); } while (0) |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 344 | # define lockdep_set_class(lock, key) do { (void)(key); } while (0) |
| 345 | # define lockdep_set_class_and_name(lock, key, name) \ |
Ingo Molnar | e25cf3d | 2008-10-17 15:55:07 +0200 | [diff] [blame] | 346 | do { (void)(key); (void)(name); } while (0) |
Peter Zijlstra | 4dfbb9d | 2006-10-11 01:45:14 -0400 | [diff] [blame] | 347 | #define lockdep_set_class_and_subclass(lock, key, sub) \ |
| 348 | do { (void)(key); } while (0) |
Andrew Morton | 07646e2 | 2006-10-11 23:45:23 -0400 | [diff] [blame] | 349 | #define lockdep_set_subclass(lock, sub) do { } while (0) |
Peter Zijlstra | 1704f47 | 2010-03-19 01:37:42 +0100 | [diff] [blame] | 350 | |
| 351 | #define lockdep_set_novalidate_class(lock) do { } while (0) |
| 352 | |
Jan Kara | 9a7aa12 | 2009-06-04 15:26:49 +0200 | [diff] [blame] | 353 | /* |
| 354 | * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP |
| 355 | * case since the result is not well defined and the caller should rather |
| 356 | * #ifdef the call himself. |
| 357 | */ |
Andrew Morton | 07646e2 | 2006-10-11 23:45:23 -0400 | [diff] [blame] | 358 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 359 | # define lockdep_reset() do { debug_locks = 1; } while (0) |
| 360 | # define lockdep_free_key_range(start, size) do { } while (0) |
Peter Zijlstra | b351d16 | 2007-10-11 22:11:12 +0200 | [diff] [blame] | 361 | # define lockdep_sys_exit() do { } while (0) |
Peter Zijlstra | d5abe66 | 2006-12-06 20:37:26 -0800 | [diff] [blame] | 362 | |
Bart Van Assche | 108c148 | 2019-02-14 15:00:53 -0800 | [diff] [blame] | 363 | static inline void lockdep_register_key(struct lock_class_key *key) |
| 364 | { |
| 365 | } |
| 366 | |
| 367 | static inline void lockdep_unregister_key(struct lock_class_key *key) |
| 368 | { |
| 369 | } |
| 370 | |
Peter Zijlstra | d5abe66 | 2006-12-06 20:37:26 -0800 | [diff] [blame] | 371 | #define lockdep_depth(tsk) (0) |
| 372 | |
Peter Zijlstra | f831948 | 2016-11-30 14:32:25 +1100 | [diff] [blame] | 373 | #define lockdep_is_held_type(l, r) (1) |
| 374 | |
Paul Bolle | 5cd3f5a | 2013-01-24 21:53:17 +0100 | [diff] [blame] | 375 | #define lockdep_assert_held(l) do { (void)(l); } while (0) |
Nikolay Borisov | 9ffbe8a | 2019-05-31 13:06:51 +0300 | [diff] [blame] | 376 | #define lockdep_assert_held_write(l) do { (void)(l); } while (0) |
Peter Zijlstra | f831948 | 2016-11-30 14:32:25 +1100 | [diff] [blame] | 377 | #define lockdep_assert_held_read(l) do { (void)(l); } while (0) |
Peter Hurley | 9a37110 | 2014-09-10 14:31:39 -0400 | [diff] [blame] | 378 | #define lockdep_assert_held_once(l) do { (void)(l); } while (0) |
Peter Zijlstra | f607c66 | 2009-07-20 19:16:29 +0200 | [diff] [blame] | 379 | |
Peter Zijlstra | 94d24fc | 2011-06-07 11:17:30 +0200 | [diff] [blame] | 380 | #define lockdep_recursing(tsk) (0) |
| 381 | |
Peter Zijlstra | e7904a2 | 2015-08-01 19:25:08 +0200 | [diff] [blame] | 382 | #define NIL_COOKIE (struct pin_cookie){ } |
| 383 | |
Arnd Bergmann | 3771b0f | 2019-03-25 13:57:57 +0100 | [diff] [blame] | 384 | #define lockdep_pin_lock(l) ({ struct pin_cookie cookie = { }; cookie; }) |
Peter Zijlstra | e7904a2 | 2015-08-01 19:25:08 +0200 | [diff] [blame] | 385 | #define lockdep_repin_lock(l, c) do { (void)(l); (void)(c); } while (0) |
| 386 | #define lockdep_unpin_lock(l, c) do { (void)(l); (void)(c); } while (0) |
Peter Zijlstra | a24fc60 | 2015-06-11 14:46:53 +0200 | [diff] [blame] | 387 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 388 | #endif /* !LOCKDEP */ |
| 389 | |
Byungchul Park | b09be67 | 2017-08-07 16:12:52 +0900 | [diff] [blame] | 390 | enum xhlock_context_t { |
| 391 | XHLOCK_HARD, |
| 392 | XHLOCK_SOFT, |
Byungchul Park | b09be67 | 2017-08-07 16:12:52 +0900 | [diff] [blame] | 393 | XHLOCK_CTX_NR, |
| 394 | }; |
| 395 | |
Boqun Feng | 52fa5bc | 2017-08-17 17:46:12 +0800 | [diff] [blame] | 396 | #define lockdep_init_map_crosslock(m, n, k, s) do {} while (0) |
Byungchul Park | b09be67 | 2017-08-07 16:12:52 +0900 | [diff] [blame] | 397 | /* |
| 398 | * To initialize a lockdep_map statically use this macro. |
| 399 | * Note that _name must not be NULL. |
| 400 | */ |
| 401 | #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ |
| 402 | { .name = (_name), .key = (void *)(_key), } |
| 403 | |
Peter Zijlstra | f52be57 | 2017-08-29 10:59:39 +0200 | [diff] [blame] | 404 | static inline void lockdep_invariant_state(bool force) {} |
Byungchul Park | b09be67 | 2017-08-07 16:12:52 +0900 | [diff] [blame] | 405 | static inline void lockdep_free_task(struct task_struct *task) {} |
Byungchul Park | b09be67 | 2017-08-07 16:12:52 +0900 | [diff] [blame] | 406 | |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 407 | #ifdef CONFIG_LOCK_STAT |
| 408 | |
| 409 | extern void lock_contended(struct lockdep_map *lock, unsigned long ip); |
Peter Zijlstra | c7e78cf | 2008-10-16 23:17:09 +0200 | [diff] [blame] | 410 | extern void lock_acquired(struct lockdep_map *lock, unsigned long ip); |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 411 | |
| 412 | #define LOCK_CONTENDED(_lock, try, lock) \ |
| 413 | do { \ |
| 414 | if (!try(_lock)) { \ |
| 415 | lock_contended(&(_lock)->dep_map, _RET_IP_); \ |
| 416 | lock(_lock); \ |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 417 | } \ |
Peter Zijlstra | c7e78cf | 2008-10-16 23:17:09 +0200 | [diff] [blame] | 418 | lock_acquired(&(_lock)->dep_map, _RET_IP_); \ |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 419 | } while (0) |
| 420 | |
Michal Hocko | 916633a | 2016-04-07 17:12:31 +0200 | [diff] [blame] | 421 | #define LOCK_CONTENDED_RETURN(_lock, try, lock) \ |
| 422 | ({ \ |
| 423 | int ____err = 0; \ |
| 424 | if (!try(_lock)) { \ |
| 425 | lock_contended(&(_lock)->dep_map, _RET_IP_); \ |
| 426 | ____err = lock(_lock); \ |
| 427 | } \ |
| 428 | if (!____err) \ |
| 429 | lock_acquired(&(_lock)->dep_map, _RET_IP_); \ |
| 430 | ____err; \ |
| 431 | }) |
| 432 | |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 433 | #else /* CONFIG_LOCK_STAT */ |
| 434 | |
| 435 | #define lock_contended(lockdep_map, ip) do {} while (0) |
Peter Zijlstra | c7e78cf | 2008-10-16 23:17:09 +0200 | [diff] [blame] | 436 | #define lock_acquired(lockdep_map, ip) do {} while (0) |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 437 | |
| 438 | #define LOCK_CONTENDED(_lock, try, lock) \ |
| 439 | lock(_lock) |
| 440 | |
Michal Hocko | 916633a | 2016-04-07 17:12:31 +0200 | [diff] [blame] | 441 | #define LOCK_CONTENDED_RETURN(_lock, try, lock) \ |
| 442 | lock(_lock) |
| 443 | |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 444 | #endif /* CONFIG_LOCK_STAT */ |
| 445 | |
Robin Holt | e8c158b | 2009-04-02 16:59:45 -0700 | [diff] [blame] | 446 | #ifdef CONFIG_LOCKDEP |
| 447 | |
| 448 | /* |
| 449 | * On lockdep we dont want the hand-coded irq-enable of |
| 450 | * _raw_*_lock_flags() code, because lockdep assumes |
| 451 | * that interrupts are not re-enabled during lock-acquire: |
| 452 | */ |
| 453 | #define LOCK_CONTENDED_FLAGS(_lock, try, lock, lockfl, flags) \ |
| 454 | LOCK_CONTENDED((_lock), (try), (lock)) |
| 455 | |
| 456 | #else /* CONFIG_LOCKDEP */ |
| 457 | |
| 458 | #define LOCK_CONTENDED_FLAGS(_lock, try, lock, lockfl, flags) \ |
| 459 | lockfl((_lock), (flags)) |
| 460 | |
| 461 | #endif /* CONFIG_LOCKDEP */ |
| 462 | |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 463 | #ifdef CONFIG_PROVE_LOCKING |
Ingo Molnar | 3117df0 | 2006-12-13 00:34:43 -0800 | [diff] [blame] | 464 | extern void print_irqtrace_events(struct task_struct *curr); |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 465 | #else |
Ingo Molnar | 3117df0 | 2006-12-13 00:34:43 -0800 | [diff] [blame] | 466 | static inline void print_irqtrace_events(struct task_struct *curr) |
| 467 | { |
| 468 | } |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 469 | #endif |
| 470 | |
| 471 | /* |
| 472 | * For trivial one-depth nesting of a lock-class, the following |
| 473 | * global define can be used. (Subsystems with multiple levels |
| 474 | * of nesting should define their own lock-nesting subclasses.) |
| 475 | */ |
| 476 | #define SINGLE_DEPTH_NESTING 1 |
| 477 | |
| 478 | /* |
| 479 | * Map the dependency ops to NOP or to real lockdep ops, depending |
| 480 | * on the per lock-class debug mode: |
| 481 | */ |
| 482 | |
Oleg Nesterov | fb9edbe | 2014-01-20 19:20:06 +0100 | [diff] [blame] | 483 | #define lock_acquire_exclusive(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i) |
| 484 | #define lock_acquire_shared(l, s, t, n, i) lock_acquire(l, s, t, 1, 1, n, i) |
| 485 | #define lock_acquire_shared_recursive(l, s, t, n, i) lock_acquire(l, s, t, 2, 1, n, i) |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 486 | |
Michel Lespinasse | a51805e | 2013-07-08 14:23:49 -0700 | [diff] [blame] | 487 | #define spin_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) |
| 488 | #define spin_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i) |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 489 | #define spin_release(l, i) lock_release(l, i) |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 490 | |
Michel Lespinasse | a51805e | 2013-07-08 14:23:49 -0700 | [diff] [blame] | 491 | #define rwlock_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) |
| 492 | #define rwlock_acquire_read(l, s, t, i) lock_acquire_shared_recursive(l, s, t, NULL, i) |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 493 | #define rwlock_release(l, i) lock_release(l, i) |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 494 | |
John Stultz | 1ca7d67 | 2013-10-07 15:51:59 -0700 | [diff] [blame] | 495 | #define seqcount_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) |
| 496 | #define seqcount_acquire_read(l, s, t, i) lock_acquire_shared_recursive(l, s, t, NULL, i) |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 497 | #define seqcount_release(l, i) lock_release(l, i) |
John Stultz | 1ca7d67 | 2013-10-07 15:51:59 -0700 | [diff] [blame] | 498 | |
Michel Lespinasse | a51805e | 2013-07-08 14:23:49 -0700 | [diff] [blame] | 499 | #define mutex_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) |
| 500 | #define mutex_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i) |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 501 | #define mutex_release(l, i) lock_release(l, i) |
Michel Lespinasse | a51805e | 2013-07-08 14:23:49 -0700 | [diff] [blame] | 502 | |
| 503 | #define rwsem_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) |
| 504 | #define rwsem_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i) |
| 505 | #define rwsem_acquire_read(l, s, t, i) lock_acquire_shared(l, s, t, NULL, i) |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 506 | #define rwsem_release(l, i) lock_release(l, i) |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 507 | |
Michel Lespinasse | a51805e | 2013-07-08 14:23:49 -0700 | [diff] [blame] | 508 | #define lock_map_acquire(l) lock_acquire_exclusive(l, 0, 0, NULL, _THIS_IP_) |
| 509 | #define lock_map_acquire_read(l) lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_) |
Paul E. McKenney | dd56af4 | 2014-08-25 20:25:06 -0700 | [diff] [blame] | 510 | #define lock_map_acquire_tryread(l) lock_acquire_shared_recursive(l, 0, 1, NULL, _THIS_IP_) |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 511 | #define lock_map_release(l) lock_release(l, _THIS_IP_) |
Peter Zijlstra | 4f3e752 | 2008-08-11 09:30:23 +0200 | [diff] [blame] | 512 | |
Peter Zijlstra | 76b189e | 2008-09-10 09:57:35 +0200 | [diff] [blame] | 513 | #ifdef CONFIG_PROVE_LOCKING |
| 514 | # define might_lock(lock) \ |
| 515 | do { \ |
| 516 | typecheck(struct lockdep_map *, &(lock)->dep_map); \ |
Oleg Nesterov | fb9edbe | 2014-01-20 19:20:06 +0100 | [diff] [blame] | 517 | lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _THIS_IP_); \ |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 518 | lock_release(&(lock)->dep_map, _THIS_IP_); \ |
Peter Zijlstra | 76b189e | 2008-09-10 09:57:35 +0200 | [diff] [blame] | 519 | } while (0) |
| 520 | # define might_lock_read(lock) \ |
| 521 | do { \ |
| 522 | typecheck(struct lockdep_map *, &(lock)->dep_map); \ |
Oleg Nesterov | fb9edbe | 2014-01-20 19:20:06 +0100 | [diff] [blame] | 523 | lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_); \ |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 524 | lock_release(&(lock)->dep_map, _THIS_IP_); \ |
Peter Zijlstra | 76b189e | 2008-09-10 09:57:35 +0200 | [diff] [blame] | 525 | } while (0) |
Daniel Vetter | e692b40 | 2019-11-04 18:37:19 +0100 | [diff] [blame] | 526 | # define might_lock_nested(lock, subclass) \ |
| 527 | do { \ |
| 528 | typecheck(struct lockdep_map *, &(lock)->dep_map); \ |
| 529 | lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL, \ |
| 530 | _THIS_IP_); \ |
Jani Nikula | 023265e | 2019-12-11 10:35:37 +0200 | [diff] [blame] | 531 | lock_release(&(lock)->dep_map, _THIS_IP_); \ |
Daniel Vetter | e692b40 | 2019-11-04 18:37:19 +0100 | [diff] [blame] | 532 | } while (0) |
Frederic Weisbecker | f54bb2e | 2017-11-06 16:01:17 +0100 | [diff] [blame] | 533 | |
Peter Zijlstra | a21ee60 | 2020-05-25 12:22:41 +0200 | [diff] [blame] | 534 | DECLARE_PER_CPU(int, hardirqs_enabled); |
| 535 | DECLARE_PER_CPU(int, hardirq_context); |
Frederic Weisbecker | f54bb2e | 2017-11-06 16:01:17 +0100 | [diff] [blame] | 536 | |
Peter Zijlstra | a21ee60 | 2020-05-25 12:22:41 +0200 | [diff] [blame] | 537 | #define lockdep_assert_irqs_enabled() \ |
| 538 | do { \ |
| 539 | WARN_ON_ONCE(debug_locks && !this_cpu_read(hardirqs_enabled)); \ |
| 540 | } while (0) |
Frederic Weisbecker | f54bb2e | 2017-11-06 16:01:17 +0100 | [diff] [blame] | 541 | |
Peter Zijlstra | a21ee60 | 2020-05-25 12:22:41 +0200 | [diff] [blame] | 542 | #define lockdep_assert_irqs_disabled() \ |
| 543 | do { \ |
| 544 | WARN_ON_ONCE(debug_locks && this_cpu_read(hardirqs_enabled)); \ |
| 545 | } while (0) |
| 546 | |
| 547 | #define lockdep_assert_in_irq() \ |
| 548 | do { \ |
| 549 | WARN_ON_ONCE(debug_locks && !this_cpu_read(hardirq_context)); \ |
| 550 | } while (0) |
Joel Fernandes (Google) | 71d8d15 | 2019-03-26 15:24:08 -0400 | [diff] [blame] | 551 | |
Ahmed S. Darwish | 8fd8ad5 | 2020-07-20 17:55:13 +0200 | [diff] [blame^] | 552 | #define lockdep_assert_preemption_enabled() \ |
| 553 | do { \ |
| 554 | WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT) && \ |
| 555 | debug_locks && \ |
| 556 | (preempt_count() != 0 || \ |
| 557 | !this_cpu_read(hardirqs_enabled))); \ |
| 558 | } while (0) |
| 559 | |
| 560 | #define lockdep_assert_preemption_disabled() \ |
| 561 | do { \ |
| 562 | WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT) && \ |
| 563 | debug_locks && \ |
| 564 | (preempt_count() == 0 && \ |
| 565 | this_cpu_read(hardirqs_enabled))); \ |
| 566 | } while (0) |
| 567 | |
Peter Zijlstra | 76b189e | 2008-09-10 09:57:35 +0200 | [diff] [blame] | 568 | #else |
| 569 | # define might_lock(lock) do { } while (0) |
| 570 | # define might_lock_read(lock) do { } while (0) |
Daniel Vetter | e692b40 | 2019-11-04 18:37:19 +0100 | [diff] [blame] | 571 | # define might_lock_nested(lock, subclass) do { } while (0) |
Peter Zijlstra | a21ee60 | 2020-05-25 12:22:41 +0200 | [diff] [blame] | 572 | |
Frederic Weisbecker | f54bb2e | 2017-11-06 16:01:17 +0100 | [diff] [blame] | 573 | # define lockdep_assert_irqs_enabled() do { } while (0) |
| 574 | # define lockdep_assert_irqs_disabled() do { } while (0) |
Joel Fernandes (Google) | 71d8d15 | 2019-03-26 15:24:08 -0400 | [diff] [blame] | 575 | # define lockdep_assert_in_irq() do { } while (0) |
Ahmed S. Darwish | 8fd8ad5 | 2020-07-20 17:55:13 +0200 | [diff] [blame^] | 576 | |
| 577 | # define lockdep_assert_preemption_enabled() do { } while (0) |
| 578 | # define lockdep_assert_preemption_disabled() do { } while (0) |
Peter Zijlstra | 76b189e | 2008-09-10 09:57:35 +0200 | [diff] [blame] | 579 | #endif |
| 580 | |
Sebastian Siewior | 8bf6c67 | 2020-03-23 16:20:19 +0100 | [diff] [blame] | 581 | #ifdef CONFIG_PROVE_RAW_LOCK_NESTING |
| 582 | |
| 583 | # define lockdep_assert_RT_in_threaded_ctx() do { \ |
| 584 | WARN_ONCE(debug_locks && !current->lockdep_recursion && \ |
Peter Zijlstra | f9ad4a5 | 2020-05-27 13:03:26 +0200 | [diff] [blame] | 585 | lockdep_hardirq_context() && \ |
Sebastian Siewior | 8bf6c67 | 2020-03-23 16:20:19 +0100 | [diff] [blame] | 586 | !(current->hardirq_threaded || current->irq_config), \ |
| 587 | "Not in threaded context on PREEMPT_RT as expected\n"); \ |
| 588 | } while (0) |
| 589 | |
| 590 | #else |
| 591 | |
| 592 | # define lockdep_assert_RT_in_threaded_ctx() do { } while (0) |
| 593 | |
| 594 | #endif |
| 595 | |
Paul E. McKenney | d24209bb | 2015-01-21 15:26:03 -0800 | [diff] [blame] | 596 | #ifdef CONFIG_LOCKDEP |
Paul E. McKenney | b3fbab0 | 2011-05-24 08:31:09 -0700 | [diff] [blame] | 597 | void lockdep_rcu_suspicious(const char *file, const int line, const char *s); |
Paul E. McKenney | d24209bb | 2015-01-21 15:26:03 -0800 | [diff] [blame] | 598 | #else |
| 599 | static inline void |
| 600 | lockdep_rcu_suspicious(const char *file, const int line, const char *s) |
| 601 | { |
| 602 | } |
Paul E. McKenney | 0632eb3 | 2010-02-22 17:04:47 -0800 | [diff] [blame] | 603 | #endif |
| 604 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 605 | #endif /* __LINUX_LOCKDEP_H */ |