aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/lockdep.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/lockdep.h')
-rw-r--r--include/linux/lockdep.h43
1 files changed, 37 insertions, 6 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 29aec6e10020..37a0361f4685 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -73,6 +73,8 @@ struct lock_class_key {
73 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; 73 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES];
74}; 74};
75 75
76#define LOCKSTAT_POINTS 4
77
76/* 78/*
77 * The lock-class itself: 79 * The lock-class itself:
78 */ 80 */
@@ -119,7 +121,8 @@ struct lock_class {
119 int name_version; 121 int name_version;
120 122
121#ifdef CONFIG_LOCK_STAT 123#ifdef CONFIG_LOCK_STAT
122 unsigned long contention_point[4]; 124 unsigned long contention_point[LOCKSTAT_POINTS];
125 unsigned long contending_point[LOCKSTAT_POINTS];
123#endif 126#endif
124}; 127};
125 128
@@ -144,6 +147,7 @@ enum bounce_type {
144 147
145struct lock_class_stats { 148struct lock_class_stats {
146 unsigned long contention_point[4]; 149 unsigned long contention_point[4];
150 unsigned long contending_point[4];
147 struct lock_time read_waittime; 151 struct lock_time read_waittime;
148 struct lock_time write_waittime; 152 struct lock_time write_waittime;
149 struct lock_time read_holdtime; 153 struct lock_time read_holdtime;
@@ -165,6 +169,7 @@ struct lockdep_map {
165 const char *name; 169 const char *name;
166#ifdef CONFIG_LOCK_STAT 170#ifdef CONFIG_LOCK_STAT
167 int cpu; 171 int cpu;
172 unsigned long ip;
168#endif 173#endif
169}; 174};
170 175
@@ -309,8 +314,15 @@ extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
309extern void lock_release(struct lockdep_map *lock, int nested, 314extern void lock_release(struct lockdep_map *lock, int nested,
310 unsigned long ip); 315 unsigned long ip);
311 316
312extern void lock_set_subclass(struct lockdep_map *lock, unsigned int subclass, 317extern void lock_set_class(struct lockdep_map *lock, const char *name,
313 unsigned long ip); 318 struct lock_class_key *key, unsigned int subclass,
319 unsigned long ip);
320
321static inline void lock_set_subclass(struct lockdep_map *lock,
322 unsigned int subclass, unsigned long ip)
323{
324 lock_set_class(lock, lock->name, lock->key, subclass, ip);
325}
314 326
315# define INIT_LOCKDEP .lockdep_recursion = 0, 327# define INIT_LOCKDEP .lockdep_recursion = 0,
316 328
@@ -328,6 +340,7 @@ static inline void lockdep_on(void)
328 340
329# define lock_acquire(l, s, t, r, c, n, i) do { } while (0) 341# define lock_acquire(l, s, t, r, c, n, i) do { } while (0)
330# define lock_release(l, n, i) do { } while (0) 342# define lock_release(l, n, i) do { } while (0)
343# define lock_set_class(l, n, k, s, i) do { } while (0)
331# define lock_set_subclass(l, s, i) do { } while (0) 344# define lock_set_subclass(l, s, i) do { } while (0)
332# define lockdep_init() do { } while (0) 345# define lockdep_init() do { } while (0)
333# define lockdep_info() do { } while (0) 346# define lockdep_info() do { } while (0)
@@ -356,7 +369,7 @@ struct lock_class_key { };
356#ifdef CONFIG_LOCK_STAT 369#ifdef CONFIG_LOCK_STAT
357 370
358extern void lock_contended(struct lockdep_map *lock, unsigned long ip); 371extern void lock_contended(struct lockdep_map *lock, unsigned long ip);
359extern void lock_acquired(struct lockdep_map *lock); 372extern void lock_acquired(struct lockdep_map *lock, unsigned long ip);
360 373
361#define LOCK_CONTENDED(_lock, try, lock) \ 374#define LOCK_CONTENDED(_lock, try, lock) \
362do { \ 375do { \
@@ -364,13 +377,13 @@ do { \
364 lock_contended(&(_lock)->dep_map, _RET_IP_); \ 377 lock_contended(&(_lock)->dep_map, _RET_IP_); \
365 lock(_lock); \ 378 lock(_lock); \
366 } \ 379 } \
367 lock_acquired(&(_lock)->dep_map); \ 380 lock_acquired(&(_lock)->dep_map, _RET_IP_); \
368} while (0) 381} while (0)
369 382
370#else /* CONFIG_LOCK_STAT */ 383#else /* CONFIG_LOCK_STAT */
371 384
372#define lock_contended(lockdep_map, ip) do {} while (0) 385#define lock_contended(lockdep_map, ip) do {} while (0)
373#define lock_acquired(lockdep_map) do {} while (0) 386#define lock_acquired(lockdep_map, ip) do {} while (0)
374 387
375#define LOCK_CONTENDED(_lock, try, lock) \ 388#define LOCK_CONTENDED(_lock, try, lock) \
376 lock(_lock) 389 lock(_lock)
@@ -481,4 +494,22 @@ static inline void print_irqtrace_events(struct task_struct *curr)
481# define lock_map_release(l) do { } while (0) 494# define lock_map_release(l) do { } while (0)
482#endif 495#endif
483 496
497#ifdef CONFIG_PROVE_LOCKING
498# define might_lock(lock) \
499do { \
500 typecheck(struct lockdep_map *, &(lock)->dep_map); \
501 lock_acquire(&(lock)->dep_map, 0, 0, 0, 2, NULL, _THIS_IP_); \
502 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
503} while (0)
504# define might_lock_read(lock) \
505do { \
506 typecheck(struct lockdep_map *, &(lock)->dep_map); \
507 lock_acquire(&(lock)->dep_map, 0, 0, 1, 2, NULL, _THIS_IP_); \
508 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
509} while (0)
510#else
511# define might_lock(lock) do { } while (0)
512# define might_lock_read(lock) do { } while (0)
513#endif
514
484#endif /* __LINUX_LOCKDEP_H */ 515#endif /* __LINUX_LOCKDEP_H */