~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/lockdep.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/lockdep.h (Version linux-6.12-rc7) and /include/linux/lockdep.h (Version linux-6.4.16)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*                                                  2 /*
  3  * Runtime locking correctness validator            3  * Runtime locking correctness validator
  4  *                                                  4  *
  5  *  Copyright (C) 2006,2007 Red Hat, Inc., Ing      5  *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
  6  *  Copyright (C) 2007 Red Hat, Inc., Peter Zi      6  *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra
  7  *                                                  7  *
  8  * see Documentation/locking/lockdep-design.rs      8  * see Documentation/locking/lockdep-design.rst for more details.
  9  */                                                 9  */
 10 #ifndef __LINUX_LOCKDEP_H                          10 #ifndef __LINUX_LOCKDEP_H
 11 #define __LINUX_LOCKDEP_H                          11 #define __LINUX_LOCKDEP_H
 12                                                    12 
 13 #include <linux/lockdep_types.h>                   13 #include <linux/lockdep_types.h>
 14 #include <linux/smp.h>                             14 #include <linux/smp.h>
 15 #include <asm/percpu.h>                            15 #include <asm/percpu.h>
 16                                                    16 
 17 struct task_struct;                                17 struct task_struct;
 18                                                    18 
 19 #ifdef CONFIG_LOCKDEP                              19 #ifdef CONFIG_LOCKDEP
 20                                                    20 
 21 #include <linux/linkage.h>                         21 #include <linux/linkage.h>
 22 #include <linux/list.h>                            22 #include <linux/list.h>
 23 #include <linux/debug_locks.h>                     23 #include <linux/debug_locks.h>
 24 #include <linux/stacktrace.h>                      24 #include <linux/stacktrace.h>
 25                                                    25 
 26 static inline void lockdep_copy_map(struct loc     26 static inline void lockdep_copy_map(struct lockdep_map *to,
 27                                     struct loc     27                                     struct lockdep_map *from)
 28 {                                                  28 {
 29         int i;                                     29         int i;
 30                                                    30 
 31         *to = *from;                               31         *to = *from;
 32         /*                                         32         /*
 33          * Since the class cache can be modifi     33          * Since the class cache can be modified concurrently we could observe
 34          * half pointers (64bit arch using 32b     34          * half pointers (64bit arch using 32bit copy insns). Therefore clear
 35          * the caches and take the performance     35          * the caches and take the performance hit.
 36          *                                         36          *
 37          * XXX it doesn't work well with lockd     37          * XXX it doesn't work well with lockdep_set_class_and_subclass(), since
 38          *     that relies on cache abuse.         38          *     that relies on cache abuse.
 39          */                                        39          */
 40         for (i = 0; i < NR_LOCKDEP_CACHING_CLA     40         for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++)
 41                 to->class_cache[i] = NULL;         41                 to->class_cache[i] = NULL;
 42 }                                                  42 }
 43                                                    43 
 44 /*                                                 44 /*
 45  * Every lock has a list of other locks that w     45  * Every lock has a list of other locks that were taken after it.
 46  * We only grow the list, never remove from it     46  * We only grow the list, never remove from it:
 47  */                                                47  */
 48 struct lock_list {                                 48 struct lock_list {
 49         struct list_head                entry;     49         struct list_head                entry;
 50         struct lock_class               *class     50         struct lock_class               *class;
 51         struct lock_class               *links     51         struct lock_class               *links_to;
 52         const struct lock_trace         *trace     52         const struct lock_trace         *trace;
 53         u16                             distan     53         u16                             distance;
 54         /* bitmap of different dependencies fr     54         /* bitmap of different dependencies from head to this */
 55         u8                              dep;       55         u8                              dep;
 56         /* used by BFS to record whether "prev     56         /* used by BFS to record whether "prev -> this" only has -(*R)-> */
 57         u8                              only_x     57         u8                              only_xr;
 58                                                    58 
 59         /*                                         59         /*
 60          * The parent field is used to impleme     60          * The parent field is used to implement breadth-first search, and the
 61          * bit 0 is reused to indicate if the      61          * bit 0 is reused to indicate if the lock has been accessed in BFS.
 62          */                                        62          */
 63         struct lock_list                *paren     63         struct lock_list                *parent;
 64 };                                                 64 };
 65                                                    65 
 66 /**                                                66 /**
 67  * struct lock_chain - lock dependency chain r     67  * struct lock_chain - lock dependency chain record
 68  *                                                 68  *
 69  * @irq_context: the same as irq_context in he     69  * @irq_context: the same as irq_context in held_lock below
 70  * @depth:       the number of held locks in t     70  * @depth:       the number of held locks in this chain
 71  * @base:        the index in chain_hlocks for     71  * @base:        the index in chain_hlocks for this chain
 72  * @entry:       the collided lock chains in l     72  * @entry:       the collided lock chains in lock_chain hash list
 73  * @chain_key:   the hash key of this lock_cha     73  * @chain_key:   the hash key of this lock_chain
 74  */                                                74  */
 75 struct lock_chain {                                75 struct lock_chain {
 76         /* see BUILD_BUG_ON()s in add_chain_ca     76         /* see BUILD_BUG_ON()s in add_chain_cache() */
 77         unsigned int                    irq_co     77         unsigned int                    irq_context :  2,
 78                                         depth      78                                         depth       :  6,
 79                                         base       79                                         base        : 24;
 80         /* 4 byte hole */                          80         /* 4 byte hole */
 81         struct hlist_node               entry;     81         struct hlist_node               entry;
 82         u64                             chain_     82         u64                             chain_key;
 83 };                                                 83 };
 84                                                    84 
                                                   >>  85 #define MAX_LOCKDEP_KEYS_BITS           13
                                                   >>  86 #define MAX_LOCKDEP_KEYS                (1UL << MAX_LOCKDEP_KEYS_BITS)
                                                   >>  87 #define INITIAL_CHAIN_KEY               -1
                                                   >>  88 
                                                   >>  89 struct held_lock {
                                                   >>  90         /*
                                                   >>  91          * One-way hash of the dependency chain up to this point. We
                                                   >>  92          * hash the hashes step by step as the dependency chain grows.
                                                   >>  93          *
                                                   >>  94          * We use it for dependency-caching and we skip detection
                                                   >>  95          * passes and dependency-updates if there is a cache-hit, so
                                                   >>  96          * it is absolutely critical for 100% coverage of the validator
                                                   >>  97          * to have a unique key value for every unique dependency path
                                                   >>  98          * that can occur in the system, to make a unique hash value
                                                   >>  99          * as likely as possible - hence the 64-bit width.
                                                   >> 100          *
                                                   >> 101          * The task struct holds the current hash value (initialized
                                                   >> 102          * with zero), here we store the previous hash value:
                                                   >> 103          */
                                                   >> 104         u64                             prev_chain_key;
                                                   >> 105         unsigned long                   acquire_ip;
                                                   >> 106         struct lockdep_map              *instance;
                                                   >> 107         struct lockdep_map              *nest_lock;
                                                   >> 108 #ifdef CONFIG_LOCK_STAT
                                                   >> 109         u64                             waittime_stamp;
                                                   >> 110         u64                             holdtime_stamp;
                                                   >> 111 #endif
                                                   >> 112         /*
                                                   >> 113          * class_idx is zero-indexed; it points to the element in
                                                   >> 114          * lock_classes this held lock instance belongs to. class_idx is in
                                                   >> 115          * the range from 0 to (MAX_LOCKDEP_KEYS-1) inclusive.
                                                   >> 116          */
                                                   >> 117         unsigned int                    class_idx:MAX_LOCKDEP_KEYS_BITS;
                                                   >> 118         /*
                                                   >> 119          * The lock-stack is unified in that the lock chains of interrupt
                                                   >> 120          * contexts nest ontop of process context chains, but we 'separate'
                                                   >> 121          * the hashes by starting with 0 if we cross into an interrupt
                                                   >> 122          * context, and we also keep do not add cross-context lock
                                                   >> 123          * dependencies - the lock usage graph walking covers that area
                                                   >> 124          * anyway, and we'd just unnecessarily increase the number of
                                                   >> 125          * dependencies otherwise. [Note: hardirq and softirq contexts
                                                   >> 126          * are separated from each other too.]
                                                   >> 127          *
                                                   >> 128          * The following field is used to detect when we cross into an
                                                   >> 129          * interrupt context:
                                                   >> 130          */
                                                   >> 131         unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */
                                                   >> 132         unsigned int trylock:1;                                         /* 16 bits */
                                                   >> 133 
                                                   >> 134         unsigned int read:2;        /* see lock_acquire() comment */
                                                   >> 135         unsigned int check:1;       /* see lock_acquire() comment */
                                                   >> 136         unsigned int hardirqs_off:1;
                                                   >> 137         unsigned int sync:1;
                                                   >> 138         unsigned int references:11;                                     /* 32 bits */
                                                   >> 139         unsigned int pin_count;
                                                   >> 140 };
                                                   >> 141 
 85 /*                                                142 /*
 86  * Initialization, self-test and debugging-out    143  * Initialization, self-test and debugging-output methods:
 87  */                                               144  */
 88 extern void lockdep_init(void);                   145 extern void lockdep_init(void);
 89 extern void lockdep_reset(void);                  146 extern void lockdep_reset(void);
 90 extern void lockdep_reset_lock(struct lockdep_    147 extern void lockdep_reset_lock(struct lockdep_map *lock);
 91 extern void lockdep_free_key_range(void *start    148 extern void lockdep_free_key_range(void *start, unsigned long size);
 92 extern asmlinkage void lockdep_sys_exit(void);    149 extern asmlinkage void lockdep_sys_exit(void);
 93 extern void lockdep_set_selftest_task(struct t    150 extern void lockdep_set_selftest_task(struct task_struct *task);
 94                                                   151 
 95 extern void lockdep_init_task(struct task_stru    152 extern void lockdep_init_task(struct task_struct *task);
 96                                                   153 
 97 /*                                                154 /*
 98  * Split the recursion counter in two to readi    155  * Split the recursion counter in two to readily detect 'off' vs recursion.
 99  */                                               156  */
100 #define LOCKDEP_RECURSION_BITS  16                157 #define LOCKDEP_RECURSION_BITS  16
101 #define LOCKDEP_OFF             (1U << LOCKDEP    158 #define LOCKDEP_OFF             (1U << LOCKDEP_RECURSION_BITS)
102 #define LOCKDEP_RECURSION_MASK  (LOCKDEP_OFF -    159 #define LOCKDEP_RECURSION_MASK  (LOCKDEP_OFF - 1)
103                                                   160 
104 /*                                                161 /*
105  * lockdep_{off,on}() are macros to avoid trac    162  * lockdep_{off,on}() are macros to avoid tracing and kprobes; not inlines due
106  * to header dependencies.                        163  * to header dependencies.
107  */                                               164  */
108                                                   165 
109 #define lockdep_off()                             166 #define lockdep_off()                                   \
110 do {                                              167 do {                                                    \
111         current->lockdep_recursion += LOCKDEP_    168         current->lockdep_recursion += LOCKDEP_OFF;      \
112 } while (0)                                       169 } while (0)
113                                                   170 
114 #define lockdep_on()                              171 #define lockdep_on()                                    \
115 do {                                              172 do {                                                    \
116         current->lockdep_recursion -= LOCKDEP_    173         current->lockdep_recursion -= LOCKDEP_OFF;      \
117 } while (0)                                       174 } while (0)
118                                                   175 
119 extern void lockdep_register_key(struct lock_c    176 extern void lockdep_register_key(struct lock_class_key *key);
120 extern void lockdep_unregister_key(struct lock    177 extern void lockdep_unregister_key(struct lock_class_key *key);
121                                                   178 
122 /*                                                179 /*
123  * These methods are used by specific locking     180  * These methods are used by specific locking variants (spinlocks,
124  * rwlocks, mutexes and rwsems) to pass init/a    181  * rwlocks, mutexes and rwsems) to pass init/acquire/release events
125  * to lockdep:                                    182  * to lockdep:
126  */                                               183  */
127                                                   184 
128 extern void lockdep_init_map_type(struct lockd    185 extern void lockdep_init_map_type(struct lockdep_map *lock, const char *name,
129         struct lock_class_key *key, int subcla    186         struct lock_class_key *key, int subclass, u8 inner, u8 outer, u8 lock_type);
130                                                   187 
131 static inline void                                188 static inline void
132 lockdep_init_map_waits(struct lockdep_map *loc    189 lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
133                        struct lock_class_key *    190                        struct lock_class_key *key, int subclass, u8 inner, u8 outer)
134 {                                                 191 {
135         lockdep_init_map_type(lock, name, key,    192         lockdep_init_map_type(lock, name, key, subclass, inner, outer, LD_LOCK_NORMAL);
136 }                                                 193 }
137                                                   194 
138 static inline void                                195 static inline void
139 lockdep_init_map_wait(struct lockdep_map *lock    196 lockdep_init_map_wait(struct lockdep_map *lock, const char *name,
140                       struct lock_class_key *k    197                       struct lock_class_key *key, int subclass, u8 inner)
141 {                                                 198 {
142         lockdep_init_map_waits(lock, name, key    199         lockdep_init_map_waits(lock, name, key, subclass, inner, LD_WAIT_INV);
143 }                                                 200 }
144                                                   201 
145 static inline void lockdep_init_map(struct loc    202 static inline void lockdep_init_map(struct lockdep_map *lock, const char *name,
146                              struct lock_class    203                              struct lock_class_key *key, int subclass)
147 {                                                 204 {
148         lockdep_init_map_wait(lock, name, key,    205         lockdep_init_map_wait(lock, name, key, subclass, LD_WAIT_INV);
149 }                                                 206 }
150                                                   207 
151 /*                                                208 /*
152  * Reinitialize a lock key - for cases where t    209  * Reinitialize a lock key - for cases where there is special locking or
153  * special initialization of locks so that the    210  * special initialization of locks so that the validator gets the scope
154  * of dependencies wrong: they are either too     211  * of dependencies wrong: they are either too broad (they need a class-split)
155  * or they are too narrow (they suffer from a     212  * or they are too narrow (they suffer from a false class-split):
156  */                                               213  */
157 #define lockdep_set_class(lock, key)              214 #define lockdep_set_class(lock, key)                            \
158         lockdep_init_map_type(&(lock)->dep_map    215         lockdep_init_map_type(&(lock)->dep_map, #key, key, 0,   \
159                               (lock)->dep_map.    216                               (lock)->dep_map.wait_type_inner,  \
160                               (lock)->dep_map.    217                               (lock)->dep_map.wait_type_outer,  \
161                               (lock)->dep_map.    218                               (lock)->dep_map.lock_type)
162                                                   219 
163 #define lockdep_set_class_and_name(lock, key,     220 #define lockdep_set_class_and_name(lock, key, name)             \
164         lockdep_init_map_type(&(lock)->dep_map    221         lockdep_init_map_type(&(lock)->dep_map, name, key, 0,   \
165                               (lock)->dep_map.    222                               (lock)->dep_map.wait_type_inner,  \
166                               (lock)->dep_map.    223                               (lock)->dep_map.wait_type_outer,  \
167                               (lock)->dep_map.    224                               (lock)->dep_map.lock_type)
168                                                   225 
169 #define lockdep_set_class_and_subclass(lock, k    226 #define lockdep_set_class_and_subclass(lock, key, sub)          \
170         lockdep_init_map_type(&(lock)->dep_map    227         lockdep_init_map_type(&(lock)->dep_map, #key, key, sub, \
171                               (lock)->dep_map.    228                               (lock)->dep_map.wait_type_inner,  \
172                               (lock)->dep_map.    229                               (lock)->dep_map.wait_type_outer,  \
173                               (lock)->dep_map.    230                               (lock)->dep_map.lock_type)
174                                                   231 
175 #define lockdep_set_subclass(lock, sub)           232 #define lockdep_set_subclass(lock, sub)                                 \
176         lockdep_init_map_type(&(lock)->dep_map    233         lockdep_init_map_type(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\
177                               (lock)->dep_map.    234                               (lock)->dep_map.wait_type_inner,          \
178                               (lock)->dep_map.    235                               (lock)->dep_map.wait_type_outer,          \
179                               (lock)->dep_map.    236                               (lock)->dep_map.lock_type)
180                                                   237 
181 /**                                            << 
182  * lockdep_set_novalidate_class: disable check << 
183  * lock                                        << 
184  * @lock: Lock to mark                         << 
185  *                                             << 
186  * Lockdep will still record that this lock ha << 
187  * instances when dumping locks                << 
188  */                                            << 
189 #define lockdep_set_novalidate_class(lock) \      238 #define lockdep_set_novalidate_class(lock) \
190         lockdep_set_class_and_name(lock, &__lo    239         lockdep_set_class_and_name(lock, &__lockdep_no_validate__, #lock)
191                                                   240 
192 /**                                            << 
193  * lockdep_set_notrack_class: disable lockdep  << 
194  * @lock: Lock to mark                         << 
195  *                                             << 
196  * Bigger hammer than lockdep_set_novalidate_c << 
197  * which takes more locks than lockdep is able << 
198  */                                            << 
199 #define lockdep_set_notrack_class(lock) \      << 
200         lockdep_set_class_and_name(lock, &__lo << 
201                                                << 
202 /*                                                241 /*
203  * Compare locking classes                        242  * Compare locking classes
204  */                                               243  */
205 #define lockdep_match_class(lock, key) lockdep    244 #define lockdep_match_class(lock, key) lockdep_match_key(&(lock)->dep_map, key)
206                                                   245 
207 static inline int lockdep_match_key(struct loc    246 static inline int lockdep_match_key(struct lockdep_map *lock,
208                                     struct loc    247                                     struct lock_class_key *key)
209 {                                                 248 {
210         return lock->key == key;                  249         return lock->key == key;
211 }                                                 250 }
212                                                   251 
213 /*                                                252 /*
214  * Acquire a lock.                                253  * Acquire a lock.
215  *                                                254  *
216  * Values for "read":                             255  * Values for "read":
217  *                                                256  *
218  *   0: exclusive (write) acquire                 257  *   0: exclusive (write) acquire
219  *   1: read-acquire (no recursion allowed)       258  *   1: read-acquire (no recursion allowed)
220  *   2: read-acquire with same-instance recurs    259  *   2: read-acquire with same-instance recursion allowed
221  *                                                260  *
222  * Values for check:                              261  * Values for check:
223  *                                                262  *
224  *   0: simple checks (freeing, held-at-exit-t    263  *   0: simple checks (freeing, held-at-exit-time, etc.)
225  *   1: full validation                           264  *   1: full validation
226  */                                               265  */
227 extern void lock_acquire(struct lockdep_map *l    266 extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
228                          int trylock, int read    267                          int trylock, int read, int check,
229                          struct lockdep_map *n    268                          struct lockdep_map *nest_lock, unsigned long ip);
230                                                   269 
231 extern void lock_release(struct lockdep_map *l    270 extern void lock_release(struct lockdep_map *lock, unsigned long ip);
232                                                   271 
233 extern void lock_sync(struct lockdep_map *lock    272 extern void lock_sync(struct lockdep_map *lock, unsigned int subclass,
234                       int read, int check, str    273                       int read, int check, struct lockdep_map *nest_lock,
235                       unsigned long ip);          274                       unsigned long ip);
236                                                   275 
237 /* lock_is_held_type() returns */                 276 /* lock_is_held_type() returns */
238 #define LOCK_STATE_UNKNOWN      -1                277 #define LOCK_STATE_UNKNOWN      -1
239 #define LOCK_STATE_NOT_HELD     0                 278 #define LOCK_STATE_NOT_HELD     0
240 #define LOCK_STATE_HELD         1                 279 #define LOCK_STATE_HELD         1
241                                                   280 
242 /*                                                281 /*
243  * Same "read" as for lock_acquire(), except -    282  * Same "read" as for lock_acquire(), except -1 means any.
244  */                                               283  */
245 extern int lock_is_held_type(const struct lock    284 extern int lock_is_held_type(const struct lockdep_map *lock, int read);
246                                                   285 
247 static inline int lock_is_held(const struct lo    286 static inline int lock_is_held(const struct lockdep_map *lock)
248 {                                                 287 {
249         return lock_is_held_type(lock, -1);       288         return lock_is_held_type(lock, -1);
250 }                                                 289 }
251                                                   290 
252 #define lockdep_is_held(lock)           lock_i    291 #define lockdep_is_held(lock)           lock_is_held(&(lock)->dep_map)
253 #define lockdep_is_held_type(lock, r)   lock_i    292 #define lockdep_is_held_type(lock, r)   lock_is_held_type(&(lock)->dep_map, (r))
254                                                   293 
255 extern void lock_set_class(struct lockdep_map     294 extern void lock_set_class(struct lockdep_map *lock, const char *name,
256                            struct lock_class_k    295                            struct lock_class_key *key, unsigned int subclass,
257                            unsigned long ip);     296                            unsigned long ip);
258                                                   297 
259 #define lock_set_novalidate_class(l, n, i) \      298 #define lock_set_novalidate_class(l, n, i) \
260         lock_set_class(l, n, &__lockdep_no_val    299         lock_set_class(l, n, &__lockdep_no_validate__, 0, i)
261                                                   300 
262 static inline void lock_set_subclass(struct lo    301 static inline void lock_set_subclass(struct lockdep_map *lock,
263                 unsigned int subclass, unsigne    302                 unsigned int subclass, unsigned long ip)
264 {                                                 303 {
265         lock_set_class(lock, lock->name, lock-    304         lock_set_class(lock, lock->name, lock->key, subclass, ip);
266 }                                                 305 }
267                                                   306 
268 extern void lock_downgrade(struct lockdep_map     307 extern void lock_downgrade(struct lockdep_map *lock, unsigned long ip);
269                                                   308 
270 #define NIL_COOKIE (struct pin_cookie){ .val =    309 #define NIL_COOKIE (struct pin_cookie){ .val = 0U, }
271                                                   310 
272 extern struct pin_cookie lock_pin_lock(struct     311 extern struct pin_cookie lock_pin_lock(struct lockdep_map *lock);
273 extern void lock_repin_lock(struct lockdep_map    312 extern void lock_repin_lock(struct lockdep_map *lock, struct pin_cookie);
274 extern void lock_unpin_lock(struct lockdep_map    313 extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie);
275                                                   314 
276 #define lockdep_depth(tsk)      (debug_locks ?    315 #define lockdep_depth(tsk)      (debug_locks ? (tsk)->lockdep_depth : 0)
277                                                   316 
278 #define lockdep_assert(cond)            \         317 #define lockdep_assert(cond)            \
279         do { WARN_ON(debug_locks && !(cond));     318         do { WARN_ON(debug_locks && !(cond)); } while (0)
280                                                   319 
281 #define lockdep_assert_once(cond)       \         320 #define lockdep_assert_once(cond)       \
282         do { WARN_ON_ONCE(debug_locks && !(con    321         do { WARN_ON_ONCE(debug_locks && !(cond)); } while (0)
283                                                   322 
284 #define lockdep_assert_held(l)          \         323 #define lockdep_assert_held(l)          \
285         lockdep_assert(lockdep_is_held(l) != L    324         lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
286                                                   325 
287 #define lockdep_assert_not_held(l)      \         326 #define lockdep_assert_not_held(l)      \
288         lockdep_assert(lockdep_is_held(l) != L    327         lockdep_assert(lockdep_is_held(l) != LOCK_STATE_HELD)
289                                                   328 
290 #define lockdep_assert_held_write(l)    \         329 #define lockdep_assert_held_write(l)    \
291         lockdep_assert(lockdep_is_held_type(l,    330         lockdep_assert(lockdep_is_held_type(l, 0))
292                                                   331 
293 #define lockdep_assert_held_read(l)     \         332 #define lockdep_assert_held_read(l)     \
294         lockdep_assert(lockdep_is_held_type(l,    333         lockdep_assert(lockdep_is_held_type(l, 1))
295                                                   334 
296 #define lockdep_assert_held_once(l)               335 #define lockdep_assert_held_once(l)             \
297         lockdep_assert_once(lockdep_is_held(l)    336         lockdep_assert_once(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
298                                                   337 
299 #define lockdep_assert_none_held_once()           338 #define lockdep_assert_none_held_once()         \
300         lockdep_assert_once(!current->lockdep_    339         lockdep_assert_once(!current->lockdep_depth)
301                                                   340 
302 #define lockdep_recursing(tsk)  ((tsk)->lockde    341 #define lockdep_recursing(tsk)  ((tsk)->lockdep_recursion)
303                                                   342 
304 #define lockdep_pin_lock(l)     lock_pin_lock(    343 #define lockdep_pin_lock(l)     lock_pin_lock(&(l)->dep_map)
305 #define lockdep_repin_lock(l,c) lock_repin_loc    344 #define lockdep_repin_lock(l,c) lock_repin_lock(&(l)->dep_map, (c))
306 #define lockdep_unpin_lock(l,c) lock_unpin_loc    345 #define lockdep_unpin_lock(l,c) lock_unpin_lock(&(l)->dep_map, (c))
307                                                   346 
308 /*                                                347 /*
309  * Must use lock_map_aquire_try() with overrid    348  * Must use lock_map_aquire_try() with override maps to avoid
310  * lockdep thinking they participate in the bl    349  * lockdep thinking they participate in the block chain.
311  */                                               350  */
312 #define DEFINE_WAIT_OVERRIDE_MAP(_name, _wait_    351 #define DEFINE_WAIT_OVERRIDE_MAP(_name, _wait_type)     \
313         struct lockdep_map _name = {              352         struct lockdep_map _name = {                    \
314                 .name = #_name "-wait-type-ove    353                 .name = #_name "-wait-type-override",   \
315                 .wait_type_inner = _wait_type,    354                 .wait_type_inner = _wait_type,          \
316                 .lock_type = LD_LOCK_WAIT_OVER    355                 .lock_type = LD_LOCK_WAIT_OVERRIDE, }
317                                                   356 
318 #else /* !CONFIG_LOCKDEP */                       357 #else /* !CONFIG_LOCKDEP */
319                                                   358 
320 static inline void lockdep_init_task(struct ta    359 static inline void lockdep_init_task(struct task_struct *task)
321 {                                                 360 {
322 }                                                 361 }
323                                                   362 
324 static inline void lockdep_off(void)              363 static inline void lockdep_off(void)
325 {                                                 364 {
326 }                                                 365 }
327                                                   366 
328 static inline void lockdep_on(void)               367 static inline void lockdep_on(void)
329 {                                                 368 {
330 }                                                 369 }
331                                                   370 
332 static inline void lockdep_set_selftest_task(s    371 static inline void lockdep_set_selftest_task(struct task_struct *task)
333 {                                                 372 {
334 }                                                 373 }
335                                                   374 
336 # define lock_acquire(l, s, t, r, c, n, i)        375 # define lock_acquire(l, s, t, r, c, n, i)      do { } while (0)
337 # define lock_release(l, i)                       376 # define lock_release(l, i)                     do { } while (0)
338 # define lock_downgrade(l, i)                     377 # define lock_downgrade(l, i)                   do { } while (0)
339 # define lock_set_class(l, n, key, s, i)          378 # define lock_set_class(l, n, key, s, i)        do { (void)(key); } while (0)
340 # define lock_set_novalidate_class(l, n, i)       379 # define lock_set_novalidate_class(l, n, i)     do { } while (0)
341 # define lock_set_subclass(l, s, i)               380 # define lock_set_subclass(l, s, i)             do { } while (0)
342 # define lockdep_init()                           381 # define lockdep_init()                         do { } while (0)
343 # define lockdep_init_map_type(lock, name, key    382 # define lockdep_init_map_type(lock, name, key, sub, inner, outer, type) \
344                 do { (void)(name); (void)(key)    383                 do { (void)(name); (void)(key); } while (0)
345 # define lockdep_init_map_waits(lock, name, ke    384 # define lockdep_init_map_waits(lock, name, key, sub, inner, outer) \
346                 do { (void)(name); (void)(key)    385                 do { (void)(name); (void)(key); } while (0)
347 # define lockdep_init_map_wait(lock, name, key    386 # define lockdep_init_map_wait(lock, name, key, sub, inner) \
348                 do { (void)(name); (void)(key)    387                 do { (void)(name); (void)(key); } while (0)
349 # define lockdep_init_map(lock, name, key, sub    388 # define lockdep_init_map(lock, name, key, sub) \
350                 do { (void)(name); (void)(key)    389                 do { (void)(name); (void)(key); } while (0)
351 # define lockdep_set_class(lock, key)             390 # define lockdep_set_class(lock, key)           do { (void)(key); } while (0)
352 # define lockdep_set_class_and_name(lock, key,    391 # define lockdep_set_class_and_name(lock, key, name) \
353                 do { (void)(key); (void)(name)    392                 do { (void)(key); (void)(name); } while (0)
354 #define lockdep_set_class_and_subclass(lock, k    393 #define lockdep_set_class_and_subclass(lock, key, sub) \
355                 do { (void)(key); } while (0)     394                 do { (void)(key); } while (0)
356 #define lockdep_set_subclass(lock, sub)           395 #define lockdep_set_subclass(lock, sub)         do { } while (0)
357                                                   396 
358 #define lockdep_set_novalidate_class(lock) do     397 #define lockdep_set_novalidate_class(lock) do { } while (0)
359 #define lockdep_set_notrack_class(lock) do { } << 
360                                                   398 
361 /*                                                399 /*
362  * We don't define lockdep_match_class() and l    400  * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP
363  * case since the result is not well defined a    401  * case since the result is not well defined and the caller should rather
364  * #ifdef the call himself.                       402  * #ifdef the call himself.
365  */                                               403  */
366                                                   404 
367 # define lockdep_reset()                do { d    405 # define lockdep_reset()                do { debug_locks = 1; } while (0)
368 # define lockdep_free_key_range(start, size)      406 # define lockdep_free_key_range(start, size)    do { } while (0)
369 # define lockdep_sys_exit()                       407 # define lockdep_sys_exit()                     do { } while (0)
370                                                   408 
371 static inline void lockdep_register_key(struct    409 static inline void lockdep_register_key(struct lock_class_key *key)
372 {                                                 410 {
373 }                                                 411 }
374                                                   412 
375 static inline void lockdep_unregister_key(stru    413 static inline void lockdep_unregister_key(struct lock_class_key *key)
376 {                                                 414 {
377 }                                                 415 }
378                                                   416 
379 #define lockdep_depth(tsk)      (0)               417 #define lockdep_depth(tsk)      (0)
380                                                   418 
381 /*                                                419 /*
382  * Dummy forward declarations, allow users to     420  * Dummy forward declarations, allow users to write less ifdef-y code
383  * and depend on dead code elimination.           421  * and depend on dead code elimination.
384  */                                               422  */
385 extern int lock_is_held(const void *);            423 extern int lock_is_held(const void *);
386 extern int lockdep_is_held(const void *);         424 extern int lockdep_is_held(const void *);
387 #define lockdep_is_held_type(l, r)                425 #define lockdep_is_held_type(l, r)              (1)
388                                                   426 
389 #define lockdep_assert(c)                         427 #define lockdep_assert(c)                       do { } while (0)
390 #define lockdep_assert_once(c)                    428 #define lockdep_assert_once(c)                  do { } while (0)
391                                                   429 
392 #define lockdep_assert_held(l)                    430 #define lockdep_assert_held(l)                  do { (void)(l); } while (0)
393 #define lockdep_assert_not_held(l)                431 #define lockdep_assert_not_held(l)              do { (void)(l); } while (0)
394 #define lockdep_assert_held_write(l)              432 #define lockdep_assert_held_write(l)            do { (void)(l); } while (0)
395 #define lockdep_assert_held_read(l)               433 #define lockdep_assert_held_read(l)             do { (void)(l); } while (0)
396 #define lockdep_assert_held_once(l)               434 #define lockdep_assert_held_once(l)             do { (void)(l); } while (0)
397 #define lockdep_assert_none_held_once() do { }    435 #define lockdep_assert_none_held_once() do { } while (0)
398                                                   436 
399 #define lockdep_recursing(tsk)                    437 #define lockdep_recursing(tsk)                  (0)
400                                                   438 
401 #define NIL_COOKIE (struct pin_cookie){ }         439 #define NIL_COOKIE (struct pin_cookie){ }
402                                                   440 
403 #define lockdep_pin_lock(l)                       441 #define lockdep_pin_lock(l)                     ({ struct pin_cookie cookie = { }; cookie; })
404 #define lockdep_repin_lock(l, c)                  442 #define lockdep_repin_lock(l, c)                do { (void)(l); (void)(c); } while (0)
405 #define lockdep_unpin_lock(l, c)                  443 #define lockdep_unpin_lock(l, c)                do { (void)(l); (void)(c); } while (0)
406                                                   444 
407 #define DEFINE_WAIT_OVERRIDE_MAP(_name, _wait_    445 #define DEFINE_WAIT_OVERRIDE_MAP(_name, _wait_type)     \
408         struct lockdep_map __maybe_unused _nam    446         struct lockdep_map __maybe_unused _name = {}
409                                                   447 
410 #endif /* !LOCKDEP */                             448 #endif /* !LOCKDEP */
411                                                   449 
412 #ifdef CONFIG_PROVE_LOCKING                    << 
413 void lockdep_set_lock_cmp_fn(struct lockdep_ma << 
414                                                << 
415 #define lock_set_cmp_fn(lock, ...)      lockde << 
416 #else                                          << 
417 #define lock_set_cmp_fn(lock, ...)      do { } << 
418 #endif                                         << 
419                                                << 
420 enum xhlock_context_t {                           450 enum xhlock_context_t {
421         XHLOCK_HARD,                              451         XHLOCK_HARD,
422         XHLOCK_SOFT,                              452         XHLOCK_SOFT,
423         XHLOCK_CTX_NR,                            453         XHLOCK_CTX_NR,
424 };                                                454 };
425                                                   455 
426 /*                                                456 /*
427  * To initialize a lockdep_map statically use     457  * To initialize a lockdep_map statically use this macro.
428  * Note that _name must not be NULL.              458  * Note that _name must not be NULL.
429  */                                               459  */
430 #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \    460 #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \
431         { .name = (_name), .key = (void *)(_ke    461         { .name = (_name), .key = (void *)(_key), }
432                                                   462 
433 static inline void lockdep_invariant_state(boo    463 static inline void lockdep_invariant_state(bool force) {}
434 static inline void lockdep_free_task(struct ta    464 static inline void lockdep_free_task(struct task_struct *task) {}
435                                                   465 
436 #ifdef CONFIG_LOCK_STAT                           466 #ifdef CONFIG_LOCK_STAT
437                                                   467 
438 extern void lock_contended(struct lockdep_map     468 extern void lock_contended(struct lockdep_map *lock, unsigned long ip);
439 extern void lock_acquired(struct lockdep_map *    469 extern void lock_acquired(struct lockdep_map *lock, unsigned long ip);
440                                                   470 
441 #define LOCK_CONTENDED(_lock, try, lock)          471 #define LOCK_CONTENDED(_lock, try, lock)                        \
442 do {                                              472 do {                                                            \
443         if (!try(_lock)) {                        473         if (!try(_lock)) {                                      \
444                 lock_contended(&(_lock)->dep_m    474                 lock_contended(&(_lock)->dep_map, _RET_IP_);    \
445                 lock(_lock);                      475                 lock(_lock);                                    \
446         }                                         476         }                                                       \
447         lock_acquired(&(_lock)->dep_map, _RET_    477         lock_acquired(&(_lock)->dep_map, _RET_IP_);                     \
448 } while (0)                                       478 } while (0)
449                                                   479 
450 #define LOCK_CONTENDED_RETURN(_lock, try, lock    480 #define LOCK_CONTENDED_RETURN(_lock, try, lock)                 \
451 ({                                                481 ({                                                              \
452         int ____err = 0;                          482         int ____err = 0;                                        \
453         if (!try(_lock)) {                        483         if (!try(_lock)) {                                      \
454                 lock_contended(&(_lock)->dep_m    484                 lock_contended(&(_lock)->dep_map, _RET_IP_);    \
455                 ____err = lock(_lock);            485                 ____err = lock(_lock);                          \
456         }                                         486         }                                                       \
457         if (!____err)                             487         if (!____err)                                           \
458                 lock_acquired(&(_lock)->dep_ma    488                 lock_acquired(&(_lock)->dep_map, _RET_IP_);     \
459         ____err;                                  489         ____err;                                                \
460 })                                                490 })
461                                                   491 
462 #else /* CONFIG_LOCK_STAT */                      492 #else /* CONFIG_LOCK_STAT */
463                                                   493 
464 #define lock_contended(lockdep_map, ip) do {}     494 #define lock_contended(lockdep_map, ip) do {} while (0)
465 #define lock_acquired(lockdep_map, ip) do {} w    495 #define lock_acquired(lockdep_map, ip) do {} while (0)
466                                                   496 
467 #define LOCK_CONTENDED(_lock, try, lock) \        497 #define LOCK_CONTENDED(_lock, try, lock) \
468         lock(_lock)                               498         lock(_lock)
469                                                   499 
470 #define LOCK_CONTENDED_RETURN(_lock, try, lock    500 #define LOCK_CONTENDED_RETURN(_lock, try, lock) \
471         lock(_lock)                               501         lock(_lock)
472                                                   502 
473 #endif /* CONFIG_LOCK_STAT */                     503 #endif /* CONFIG_LOCK_STAT */
474                                                   504 
475 #ifdef CONFIG_PROVE_LOCKING                       505 #ifdef CONFIG_PROVE_LOCKING
476 extern void print_irqtrace_events(struct task_    506 extern void print_irqtrace_events(struct task_struct *curr);
477 #else                                             507 #else
478 static inline void print_irqtrace_events(struc    508 static inline void print_irqtrace_events(struct task_struct *curr)
479 {                                                 509 {
480 }                                                 510 }
481 #endif                                            511 #endif
482                                                   512 
483 /* Variable used to make lockdep treat read_lo    513 /* Variable used to make lockdep treat read_lock() as recursive in selftests */
484 #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS         514 #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
485 extern unsigned int force_read_lock_recursive;    515 extern unsigned int force_read_lock_recursive;
486 #else /* CONFIG_DEBUG_LOCKING_API_SELFTESTS */    516 #else /* CONFIG_DEBUG_LOCKING_API_SELFTESTS */
487 #define force_read_lock_recursive 0               517 #define force_read_lock_recursive 0
488 #endif /* CONFIG_DEBUG_LOCKING_API_SELFTESTS *    518 #endif /* CONFIG_DEBUG_LOCKING_API_SELFTESTS */
489                                                   519 
490 #ifdef CONFIG_LOCKDEP                             520 #ifdef CONFIG_LOCKDEP
491 extern bool read_lock_is_recursive(void);         521 extern bool read_lock_is_recursive(void);
492 #else /* CONFIG_LOCKDEP */                        522 #else /* CONFIG_LOCKDEP */
493 /* If !LOCKDEP, the value is meaningless */       523 /* If !LOCKDEP, the value is meaningless */
494 #define read_lock_is_recursive() 0                524 #define read_lock_is_recursive() 0
495 #endif                                            525 #endif
496                                                   526 
497 /*                                                527 /*
498  * For trivial one-depth nesting of a lock-cla    528  * For trivial one-depth nesting of a lock-class, the following
499  * global define can be used. (Subsystems with    529  * global define can be used. (Subsystems with multiple levels
500  * of nesting should define their own lock-nes    530  * of nesting should define their own lock-nesting subclasses.)
501  */                                               531  */
502 #define SINGLE_DEPTH_NESTING                      532 #define SINGLE_DEPTH_NESTING                    1
503                                                   533 
504 /*                                                534 /*
505  * Map the dependency ops to NOP or to real lo    535  * Map the dependency ops to NOP or to real lockdep ops, depending
506  * on the per lock-class debug mode:              536  * on the per lock-class debug mode:
507  */                                               537  */
508                                                   538 
509 #define lock_acquire_exclusive(l, s, t, n, i)     539 #define lock_acquire_exclusive(l, s, t, n, i)           lock_acquire(l, s, t, 0, 1, n, i)
510 #define lock_acquire_shared(l, s, t, n, i)        540 #define lock_acquire_shared(l, s, t, n, i)              lock_acquire(l, s, t, 1, 1, n, i)
511 #define lock_acquire_shared_recursive(l, s, t,    541 #define lock_acquire_shared_recursive(l, s, t, n, i)    lock_acquire(l, s, t, 2, 1, n, i)
512                                                   542 
513 #define spin_acquire(l, s, t, i)                  543 #define spin_acquire(l, s, t, i)                lock_acquire_exclusive(l, s, t, NULL, i)
514 #define spin_acquire_nest(l, s, t, n, i)          544 #define spin_acquire_nest(l, s, t, n, i)        lock_acquire_exclusive(l, s, t, n, i)
515 #define spin_release(l, i)                        545 #define spin_release(l, i)                      lock_release(l, i)
516                                                   546 
517 #define rwlock_acquire(l, s, t, i)                547 #define rwlock_acquire(l, s, t, i)              lock_acquire_exclusive(l, s, t, NULL, i)
518 #define rwlock_acquire_read(l, s, t, i)           548 #define rwlock_acquire_read(l, s, t, i)                                 \
519 do {                                              549 do {                                                                    \
520         if (read_lock_is_recursive())             550         if (read_lock_is_recursive())                                   \
521                 lock_acquire_shared_recursive(    551                 lock_acquire_shared_recursive(l, s, t, NULL, i);        \
522         else                                      552         else                                                            \
523                 lock_acquire_shared(l, s, t, N    553                 lock_acquire_shared(l, s, t, NULL, i);                  \
524 } while (0)                                       554 } while (0)
525                                                   555 
526 #define rwlock_release(l, i)                      556 #define rwlock_release(l, i)                    lock_release(l, i)
527                                                   557 
528 #define seqcount_acquire(l, s, t, i)              558 #define seqcount_acquire(l, s, t, i)            lock_acquire_exclusive(l, s, t, NULL, i)
529 #define seqcount_acquire_read(l, s, t, i)         559 #define seqcount_acquire_read(l, s, t, i)       lock_acquire_shared_recursive(l, s, t, NULL, i)
530 #define seqcount_release(l, i)                    560 #define seqcount_release(l, i)                  lock_release(l, i)
531                                                   561 
532 #define mutex_acquire(l, s, t, i)                 562 #define mutex_acquire(l, s, t, i)               lock_acquire_exclusive(l, s, t, NULL, i)
533 #define mutex_acquire_nest(l, s, t, n, i)         563 #define mutex_acquire_nest(l, s, t, n, i)       lock_acquire_exclusive(l, s, t, n, i)
534 #define mutex_release(l, i)                       564 #define mutex_release(l, i)                     lock_release(l, i)
535                                                   565 
536 #define rwsem_acquire(l, s, t, i)                 566 #define rwsem_acquire(l, s, t, i)               lock_acquire_exclusive(l, s, t, NULL, i)
537 #define rwsem_acquire_nest(l, s, t, n, i)         567 #define rwsem_acquire_nest(l, s, t, n, i)       lock_acquire_exclusive(l, s, t, n, i)
538 #define rwsem_acquire_read(l, s, t, i)            568 #define rwsem_acquire_read(l, s, t, i)          lock_acquire_shared(l, s, t, NULL, i)
539 #define rwsem_release(l, i)                       569 #define rwsem_release(l, i)                     lock_release(l, i)
540                                                   570 
541 #define lock_map_acquire(l)                       571 #define lock_map_acquire(l)                     lock_acquire_exclusive(l, 0, 0, NULL, _THIS_IP_)
542 #define lock_map_acquire_try(l)                   572 #define lock_map_acquire_try(l)                 lock_acquire_exclusive(l, 0, 1, NULL, _THIS_IP_)
543 #define lock_map_acquire_read(l)                  573 #define lock_map_acquire_read(l)                lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_)
544 #define lock_map_acquire_tryread(l)               574 #define lock_map_acquire_tryread(l)             lock_acquire_shared_recursive(l, 0, 1, NULL, _THIS_IP_)
545 #define lock_map_release(l)                       575 #define lock_map_release(l)                     lock_release(l, _THIS_IP_)
546 #define lock_map_sync(l)                          576 #define lock_map_sync(l)                        lock_sync(l, 0, 0, 1, NULL, _THIS_IP_)
547                                                   577 
548 #ifdef CONFIG_PROVE_LOCKING                       578 #ifdef CONFIG_PROVE_LOCKING
549 # define might_lock(lock)                         579 # define might_lock(lock)                                               \
550 do {                                              580 do {                                                                    \
551         typecheck(struct lockdep_map *, &(lock    581         typecheck(struct lockdep_map *, &(lock)->dep_map);              \
552         lock_acquire(&(lock)->dep_map, 0, 0, 0    582         lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _THIS_IP_);    \
553         lock_release(&(lock)->dep_map, _THIS_I    583         lock_release(&(lock)->dep_map, _THIS_IP_);                      \
554 } while (0)                                       584 } while (0)
555 # define might_lock_read(lock)                    585 # define might_lock_read(lock)                                          \
556 do {                                              586 do {                                                                    \
557         typecheck(struct lockdep_map *, &(lock    587         typecheck(struct lockdep_map *, &(lock)->dep_map);              \
558         lock_acquire(&(lock)->dep_map, 0, 0, 1    588         lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_);    \
559         lock_release(&(lock)->dep_map, _THIS_I    589         lock_release(&(lock)->dep_map, _THIS_IP_);                      \
560 } while (0)                                       590 } while (0)
561 # define might_lock_nested(lock, subclass)        591 # define might_lock_nested(lock, subclass)                              \
562 do {                                              592 do {                                                                    \
563         typecheck(struct lockdep_map *, &(lock    593         typecheck(struct lockdep_map *, &(lock)->dep_map);              \
564         lock_acquire(&(lock)->dep_map, subclas    594         lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL,         \
565                      _THIS_IP_);                  595                      _THIS_IP_);                                        \
566         lock_release(&(lock)->dep_map, _THIS_I    596         lock_release(&(lock)->dep_map, _THIS_IP_);                      \
567 } while (0)                                       597 } while (0)
568                                                   598 
569 DECLARE_PER_CPU(int, hardirqs_enabled);           599 DECLARE_PER_CPU(int, hardirqs_enabled);
570 DECLARE_PER_CPU(int, hardirq_context);            600 DECLARE_PER_CPU(int, hardirq_context);
571 DECLARE_PER_CPU(unsigned int, lockdep_recursio    601 DECLARE_PER_CPU(unsigned int, lockdep_recursion);
572                                                   602 
573 #define __lockdep_enabled       (debug_locks &    603 #define __lockdep_enabled       (debug_locks && !this_cpu_read(lockdep_recursion))
574                                                   604 
575 #define lockdep_assert_irqs_enabled()             605 #define lockdep_assert_irqs_enabled()                                   \
576 do {                                              606 do {                                                                    \
577         WARN_ON_ONCE(__lockdep_enabled && !thi    607         WARN_ON_ONCE(__lockdep_enabled && !this_cpu_read(hardirqs_enabled)); \
578 } while (0)                                       608 } while (0)
579                                                   609 
580 #define lockdep_assert_irqs_disabled()            610 #define lockdep_assert_irqs_disabled()                                  \
581 do {                                              611 do {                                                                    \
582         WARN_ON_ONCE(__lockdep_enabled && this    612         WARN_ON_ONCE(__lockdep_enabled && this_cpu_read(hardirqs_enabled)); \
583 } while (0)                                       613 } while (0)
584                                                   614 
585 #define lockdep_assert_in_irq()                   615 #define lockdep_assert_in_irq()                                         \
586 do {                                              616 do {                                                                    \
587         WARN_ON_ONCE(__lockdep_enabled && !thi    617         WARN_ON_ONCE(__lockdep_enabled && !this_cpu_read(hardirq_context)); \
588 } while (0)                                       618 } while (0)
589                                                   619 
590 #define lockdep_assert_no_hardirq()            << 
591 do {                                           << 
592         WARN_ON_ONCE(__lockdep_enabled && (thi << 
593                                            !th << 
594 } while (0)                                    << 
595                                                << 
596 #define lockdep_assert_preemption_enabled()       620 #define lockdep_assert_preemption_enabled()                             \
597 do {                                              621 do {                                                                    \
598         WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT    622         WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT)   &&              \
599                      __lockdep_enabled            623                      __lockdep_enabled                  &&              \
600                      (preempt_count() != 0        624                      (preempt_count() != 0              ||              \
601                       !this_cpu_read(hardirqs_    625                       !this_cpu_read(hardirqs_enabled)));               \
602 } while (0)                                       626 } while (0)
603                                                   627 
604 #define lockdep_assert_preemption_disabled()      628 #define lockdep_assert_preemption_disabled()                            \
605 do {                                              629 do {                                                                    \
606         WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT    630         WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT)   &&              \
607                      __lockdep_enabled            631                      __lockdep_enabled                  &&              \
608                      (preempt_count() == 0        632                      (preempt_count() == 0              &&              \
609                       this_cpu_read(hardirqs_e    633                       this_cpu_read(hardirqs_enabled)));                \
610 } while (0)                                       634 } while (0)
611                                                   635 
612 /*                                                636 /*
613  * Acceptable for protecting per-CPU resources    637  * Acceptable for protecting per-CPU resources accessed from BH.
614  * Much like in_softirq() - semantics are ambi    638  * Much like in_softirq() - semantics are ambiguous, use carefully.
615  */                                               639  */
616 #define lockdep_assert_in_softirq()               640 #define lockdep_assert_in_softirq()                                     \
617 do {                                              641 do {                                                                    \
618         WARN_ON_ONCE(__lockdep_enabled            642         WARN_ON_ONCE(__lockdep_enabled                  &&              \
619                      (!in_softirq() || in_irq(    643                      (!in_softirq() || in_irq() || in_nmi()));          \
620 } while (0)                                       644 } while (0)
621                                                   645 
622 extern void lockdep_assert_in_softirq_func(voi << 
623                                                << 
624 #else                                             646 #else
625 # define might_lock(lock) do { } while (0)        647 # define might_lock(lock) do { } while (0)
626 # define might_lock_read(lock) do { } while (0    648 # define might_lock_read(lock) do { } while (0)
627 # define might_lock_nested(lock, subclass) do     649 # define might_lock_nested(lock, subclass) do { } while (0)
628                                                   650 
629 # define lockdep_assert_irqs_enabled() do { }     651 # define lockdep_assert_irqs_enabled() do { } while (0)
630 # define lockdep_assert_irqs_disabled() do { }    652 # define lockdep_assert_irqs_disabled() do { } while (0)
631 # define lockdep_assert_in_irq() do { } while     653 # define lockdep_assert_in_irq() do { } while (0)
632 # define lockdep_assert_no_hardirq() do { } wh << 
633                                                   654 
634 # define lockdep_assert_preemption_enabled() d    655 # define lockdep_assert_preemption_enabled() do { } while (0)
635 # define lockdep_assert_preemption_disabled()     656 # define lockdep_assert_preemption_disabled() do { } while (0)
636 # define lockdep_assert_in_softirq() do { } wh    657 # define lockdep_assert_in_softirq() do { } while (0)
637 # define lockdep_assert_in_softirq_func() do { << 
638 #endif                                            658 #endif
639                                                   659 
640 #ifdef CONFIG_PROVE_RAW_LOCK_NESTING              660 #ifdef CONFIG_PROVE_RAW_LOCK_NESTING
641                                                   661 
642 # define lockdep_assert_RT_in_threaded_ctx() d    662 # define lockdep_assert_RT_in_threaded_ctx() do {                       \
643                 WARN_ONCE(debug_locks && !curr    663                 WARN_ONCE(debug_locks && !current->lockdep_recursion && \
644                           lockdep_hardirq_cont    664                           lockdep_hardirq_context() &&                  \
645                           !(current->hardirq_t    665                           !(current->hardirq_threaded || current->irq_config),  \
646                           "Not in threaded con    666                           "Not in threaded context on PREEMPT_RT as expected\n");       \
647 } while (0)                                       667 } while (0)
648                                                   668 
649 #else                                             669 #else
650                                                   670 
651 # define lockdep_assert_RT_in_threaded_ctx() d    671 # define lockdep_assert_RT_in_threaded_ctx() do { } while (0)
652                                                   672 
653 #endif                                            673 #endif
654                                                   674 
655 #ifdef CONFIG_LOCKDEP                             675 #ifdef CONFIG_LOCKDEP
656 void lockdep_rcu_suspicious(const char *file,     676 void lockdep_rcu_suspicious(const char *file, const int line, const char *s);
657 #else                                             677 #else
658 static inline void                                678 static inline void
659 lockdep_rcu_suspicious(const char *file, const    679 lockdep_rcu_suspicious(const char *file, const int line, const char *s)
660 {                                                 680 {
661 }                                                 681 }
662 #endif                                            682 #endif
663                                                   683 
664 #endif /* __LINUX_LOCKDEP_H */                    684 #endif /* __LINUX_LOCKDEP_H */
665                                                   685 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php