@@ -198,6 +198,63 @@ struct lockdep_map {
198
198
199
199
struct pin_cookie { unsigned int val ; };
200
200
201
+ #define MAX_LOCKDEP_KEYS_BITS 13
202
+ #define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS)
203
+ #define INITIAL_CHAIN_KEY -1
204
+
205
+ struct held_lock {
206
+ /*
207
+ * One-way hash of the dependency chain up to this point. We
208
+ * hash the hashes step by step as the dependency chain grows.
209
+ *
210
+ * We use it for dependency-caching and we skip detection
211
+ * passes and dependency-updates if there is a cache-hit, so
212
+ * it is absolutely critical for 100% coverage of the validator
213
+ * to have a unique key value for every unique dependency path
214
+ * that can occur in the system, to make a unique hash value
215
+ * as likely as possible - hence the 64-bit width.
216
+ *
217
+ * The task struct holds the current hash value (initialized
218
+ * with zero), here we store the previous hash value:
219
+ */
220
+ u64 prev_chain_key ;
221
+ unsigned long acquire_ip ;
222
+ struct lockdep_map * instance ;
223
+ struct lockdep_map * nest_lock ;
224
+ #ifdef CONFIG_LOCK_STAT
225
+ u64 waittime_stamp ;
226
+ u64 holdtime_stamp ;
227
+ #endif
228
+ /*
229
+ * class_idx is zero-indexed; it points to the element in
230
+ * lock_classes this held lock instance belongs to. class_idx is in
231
+ * the range from 0 to (MAX_LOCKDEP_KEYS-1) inclusive.
232
+ */
233
+ unsigned int class_idx :MAX_LOCKDEP_KEYS_BITS ;
234
+ /*
235
+ * The lock-stack is unified in that the lock chains of interrupt
236
+ * contexts nest ontop of process context chains, but we 'separate'
237
+ * the hashes by starting with 0 if we cross into an interrupt
238
+ * context, and we also keep do not add cross-context lock
239
+ * dependencies - the lock usage graph walking covers that area
240
+ * anyway, and we'd just unnecessarily increase the number of
241
+ * dependencies otherwise. [Note: hardirq and softirq contexts
242
+ * are separated from each other too.]
243
+ *
244
+ * The following field is used to detect when we cross into an
245
+ * interrupt context:
246
+ */
247
+ unsigned int irq_context :2 ; /* bit 0 - soft, bit 1 - hard */
248
+ unsigned int trylock :1 ; /* 16 bits */
249
+
250
+ unsigned int read :2 ; /* see lock_acquire() comment */
251
+ unsigned int check :1 ; /* see lock_acquire() comment */
252
+ unsigned int hardirqs_off :1 ;
253
+ unsigned int sync :1 ;
254
+ unsigned int references :11 ; /* 32 bits */
255
+ unsigned int pin_count ;
256
+ };
257
+
201
258
#else /* !CONFIG_LOCKDEP */
202
259
203
260
/*
0 commit comments