include/linux/lockdep.h
changeset 2 d1f6d8b6f81c
parent 0 aa628870c1d3
equal deleted inserted replaced
1:0056487c491e 2:d1f6d8b6f81c
    71 
    71 
    72 struct lock_class_key {
    72 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  */
    79 struct lock_class {
    81 struct lock_class {
    80 	/*
    82 	/*
   117 
   119 
   118 	const char			*name;
   120 	const char			*name;
   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 
   126 #ifdef CONFIG_LOCK_STAT
   129 #ifdef CONFIG_LOCK_STAT
   127 struct lock_time {
   130 struct lock_time {
   142 	bounce_contended = bounce_contended_write,
   145 	bounce_contended = bounce_contended_write,
   143 };
   146 };
   144 
   147 
   145 struct lock_class_stats {
   148 struct 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;
   150 	struct lock_time		write_holdtime;
   154 	struct lock_time		write_holdtime;
   151 	unsigned long			bounces[nr_bounce_types];
   155 	unsigned long			bounces[nr_bounce_types];
   163 	struct lock_class_key		*key;
   167 	struct lock_class_key		*key;
   164 	struct lock_class		*class_cache;
   168 	struct lock_class		*class_cache;
   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 
   171 /*
   176 /*
   172  * Every lock has a list of other locks that were taken after it.
   177  * Every lock has a list of other locks that were taken after it.
   307 			 struct lockdep_map *nest_lock, unsigned long ip);
   312 			 struct lockdep_map *nest_lock, unsigned long ip);
   308 
   313 
   309 extern void lock_release(struct lockdep_map *lock, int nested,
   314 extern void lock_release(struct lockdep_map *lock, int nested,
   310 			 unsigned long ip);
   315 			 unsigned long ip);
   311 
   316 
   312 extern void lock_set_subclass(struct lockdep_map *lock, unsigned int subclass,
   317 extern 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 
       
   321 static 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 
   317 #define lockdep_depth(tsk)	(debug_locks ? (tsk)->lockdep_depth : 0)
   329 #define lockdep_depth(tsk)	(debug_locks ? (tsk)->lockdep_depth : 0)
   318 
   330 
   326 {
   338 {
   327 }
   339 }
   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)
   334 # define lockdep_init_map(lock, name, key, sub) \
   347 # define lockdep_init_map(lock, name, key, sub) \
   335 		do { (void)(name); (void)(key); } while (0)
   348 		do { (void)(name); (void)(key); } while (0)
   354 #endif /* !LOCKDEP */
   367 #endif /* !LOCKDEP */
   355 
   368 
   356 #ifdef CONFIG_LOCK_STAT
   369 #ifdef CONFIG_LOCK_STAT
   357 
   370 
   358 extern void lock_contended(struct lockdep_map *lock, unsigned long ip);
   371 extern void lock_contended(struct lockdep_map *lock, unsigned long ip);
   359 extern void lock_acquired(struct lockdep_map *lock);
   372 extern 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)			\
   362 do {								\
   375 do {								\
   363 	if (!try(_lock)) {					\
   376 	if (!try(_lock)) {					\
   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)
   377 
   390 
   378 #endif /* CONFIG_LOCK_STAT */
   391 #endif /* CONFIG_LOCK_STAT */
   379 
   392 
   380 #if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS)
   393 #ifdef CONFIG_GENERIC_HARDIRQS
   381 extern void early_init_irq_lock_class(void);
   394 extern void early_init_irq_lock_class(void);
   382 #else
   395 #else
   383 static inline void early_init_irq_lock_class(void)
   396 static inline void early_init_irq_lock_class(void)
   384 {
   397 {
   385 }
   398 }
   479 #else
   492 #else
   480 # define lock_map_acquire(l)			do { } while (0)
   493 # define lock_map_acquire(l)			do { } while (0)
   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) 						\
       
   499 do {									\
       
   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) 						\
       
   505 do {									\
       
   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 */