Subversion Repositories Kolibri OS

Rev

Rev 5056 | Rev 6336 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5056 Rev 5270
Line 2... Line 2...
2
 * Runtime locking correctness validator
2
 * Runtime locking correctness validator
3
 *
3
 *
4
 *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar 
4
 *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar 
5
 *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra 
5
 *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra 
6
 *
6
 *
7
 * see Documentation/lockdep-design.txt for more details.
7
 * see Documentation/locking/lockdep-design.txt for more details.
8
 */
8
 */
9
#ifndef __LINUX_LOCKDEP_H
9
#ifndef __LINUX_LOCKDEP_H
10
#define __LINUX_LOCKDEP_H
10
#define __LINUX_LOCKDEP_H
Line 11... Line 11...
11
 
11
 
12
struct task_struct;
12
struct task_struct;
Line -... Line 13...
-
 
13
struct lockdep_map;
-
 
14
 
-
 
15
/* for sysctl */
-
 
16
extern int prove_locking;
13
struct lockdep_map;
17
extern int lock_stat;
Line 14... Line 18...
14
 
18
 
15
#ifdef CONFIG_LOCKDEP
19
#ifdef CONFIG_LOCKDEP
16
 
20
 
Line 49... Line 53...
49
 
53
 
50
struct lock_class_key {
54
struct lock_class_key {
51
	struct lockdep_subclass_key	subkeys[MAX_LOCKDEP_SUBCLASSES];
55
	struct lockdep_subclass_key	subkeys[MAX_LOCKDEP_SUBCLASSES];
Line -... Line 56...
-
 
56
};
-
 
57
 
52
};
58
extern struct lock_class_key __lockdep_no_validate__;
Line 53... Line 59...
53
 
59
 
54
#define LOCKSTAT_POINTS		4
60
#define LOCKSTAT_POINTS		4
55
 
61
 
Line 149... Line 155...
149
	int				cpu;
155
	int				cpu;
150
	unsigned long			ip;
156
	unsigned long			ip;
151
#endif
157
#endif
152
};
158
};
Line -... Line 159...
-
 
159
 
-
 
160
static inline void lockdep_copy_map(struct lockdep_map *to,
-
 
161
				    struct lockdep_map *from)
-
 
162
{
-
 
163
	int i;
-
 
164
 
-
 
165
	*to = *from;
-
 
166
	/*
-
 
167
	 * Since the class cache can be modified concurrently we could observe
-
 
168
	 * half pointers (64bit arch using 32bit copy insns). Therefore clear
-
 
169
	 * the caches and take the performance hit.
-
 
170
	 *
-
 
171
	 * XXX it doesn't work well with lockdep_set_class_and_subclass(), since
-
 
172
	 *     that relies on cache abuse.
-
 
173
	 */
-
 
174
	for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++)
-
 
175
		to->class_cache[i] = NULL;
-
 
176
}
153
 
177
 
154
/*
178
/*
155
 * Every lock has a list of other locks that were taken after it.
179
 * Every lock has a list of other locks that were taken after it.
156
 * We only grow the list, never remove from it:
180
 * We only grow the list, never remove from it:
157
 */
181
 */
Line 336... Line 360...
336
 
360
 
337
#define lockdep_assert_held(l)	do {				\
361
#define lockdep_assert_held(l)	do {				\
338
		WARN_ON(debug_locks && !lockdep_is_held(l));	\
362
		WARN_ON(debug_locks && !lockdep_is_held(l));	\
Line -... Line 363...
-
 
363
	} while (0)
-
 
364
 
-
 
365
#define lockdep_assert_held_once(l)	do {				\
-
 
366
		WARN_ON_ONCE(debug_locks && !lockdep_is_held(l));	\
339
	} while (0)
367
	} while (0)
Line 340... Line 368...
340
 
368
 
Line 341... Line 369...
341
#define lockdep_recursing(tsk)	((tsk)->lockdep_recursion)
369
#define lockdep_recursing(tsk)	((tsk)->lockdep_recursion)
Line 386... Line 414...
386
struct lock_class_key { };
414
struct lock_class_key { };
Line 387... Line 415...
387
 
415
 
Line 388... Line 416...
388
#define lockdep_depth(tsk)	(0)
416
#define lockdep_depth(tsk)	(0)
-
 
417
 
Line 389... Line 418...
389
 
418
#define lockdep_assert_held(l)			do { (void)(l); } while (0)
Line 390... Line 419...
390
#define lockdep_assert_held(l)			do { (void)(l); } while (0)
419
#define lockdep_assert_held_once(l)		do { (void)(l); } while (0)
Line 452... Line 481...
452
/*
481
/*
453
 * Map the dependency ops to NOP or to real lockdep ops, depending
482
 * Map the dependency ops to NOP or to real lockdep ops, depending
454
 * on the per lock-class debug mode:
483
 * on the per lock-class debug mode:
455
 */
484
 */
Line 456... Line 485...
456
 
485
 
457
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-
 
458
# ifdef CONFIG_PROVE_LOCKING
486
#define lock_acquire_exclusive(l, s, t, n, i)		lock_acquire(l, s, t, 0, 1, n, i)
459
#  define spin_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, NULL, i)
487
#define lock_acquire_shared(l, s, t, n, i)		lock_acquire(l, s, t, 1, 1, n, i)
460
#  define spin_acquire_nest(l, s, t, n, i)	lock_acquire(l, s, t, 0, 2, n, i)
488
#define lock_acquire_shared_recursive(l, s, t, n, i)	lock_acquire(l, s, t, 2, 1, n, i)
461
# else
489
 
462
#  define spin_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, NULL, i)
490
#define spin_acquire(l, s, t, i)		lock_acquire_exclusive(l, s, t, NULL, i)
463
#  define spin_acquire_nest(l, s, t, n, i)	lock_acquire(l, s, t, 0, 1, NULL, i)
-
 
464
# endif
491
#define spin_acquire_nest(l, s, t, n, i)	lock_acquire_exclusive(l, s, t, n, i)
465
# define spin_release(l, n, i)			lock_release(l, n, i)
-
 
466
#else
-
 
467
# define spin_acquire(l, s, t, i)		do { } while (0)
-
 
468
# define spin_release(l, n, i)			do { } while (0)
-
 
Line 469... Line -...
469
#endif
-
 
470
 
-
 
471
#ifdef CONFIG_DEBUG_LOCK_ALLOC
492
#define spin_release(l, n, i)			lock_release(l, n, i)
472
# ifdef CONFIG_PROVE_LOCKING
-
 
473
#  define rwlock_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, NULL, i)
-
 
474
#  define rwlock_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 2, 2, NULL, i)
-
 
475
# else
493
 
476
#  define rwlock_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, NULL, i)
-
 
477
#  define rwlock_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 2, 1, NULL, i)
494
#define rwlock_acquire(l, s, t, i)		lock_acquire_exclusive(l, s, t, NULL, i)
478
# endif
-
 
479
# define rwlock_release(l, n, i)		lock_release(l, n, i)
-
 
480
#else
-
 
481
# define rwlock_acquire(l, s, t, i)		do { } while (0)
-
 
482
# define rwlock_acquire_read(l, s, t, i)	do { } while (0)
-
 
Line 483... Line 495...
483
# define rwlock_release(l, n, i)		do { } while (0)
495
#define rwlock_acquire_read(l, s, t, i)		lock_acquire_shared_recursive(l, s, t, NULL, i)
484
#endif
-
 
485
 
496
#define rwlock_release(l, n, i)			lock_release(l, n, i)
486
#ifdef CONFIG_DEBUG_LOCK_ALLOC
497
 
487
# ifdef CONFIG_PROVE_LOCKING
498
#define seqcount_acquire(l, s, t, i)		lock_acquire_exclusive(l, s, t, NULL, i)
488
#  define mutex_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, NULL, i)
499
#define seqcount_acquire_read(l, s, t, i)	lock_acquire_shared_recursive(l, s, t, NULL, i)
489
#  define mutex_acquire_nest(l, s, t, n, i)	lock_acquire(l, s, t, 0, 2, n, i)
500
#define seqcount_release(l, n, i)		lock_release(l, n, i)
490
# else
-
 
491
#  define mutex_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, NULL, i)
501
 
492
#  define mutex_acquire_nest(l, s, t, n, i)	lock_acquire(l, s, t, 0, 1, n, i)
-
 
493
# endif
-
 
494
# define mutex_release(l, n, i)			lock_release(l, n, i)
-
 
495
#else
-
 
496
# define mutex_acquire(l, s, t, i)		do { } while (0)
-
 
Line 497... Line -...
497
# define mutex_acquire_nest(l, s, t, n, i)	do { } while (0)
-
 
498
# define mutex_release(l, n, i)			do { } while (0)
-
 
499
#endif
502
#define mutex_acquire(l, s, t, i)		lock_acquire_exclusive(l, s, t, NULL, i)
500
 
-
 
501
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-
 
502
# ifdef CONFIG_PROVE_LOCKING
-
 
503
#  define rwsem_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, NULL, i)
-
 
504
#  define rwsem_acquire_nest(l, s, t, n, i)	lock_acquire(l, s, t, 0, 2, n, i)
503
#define mutex_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(l, s, t, 1, 2, NULL, i)
504
#define mutex_release(l, n, i)			lock_release(l, n, i)
506
# else
-
 
507
#  define rwsem_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, NULL, i)
505
 
508
#  define rwsem_acquire_nest(l, s, t, n, i)	lock_acquire(l, s, t, 0, 1, n, i)
-
 
509
#  define rwsem_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 1, 1, NULL, i)
-
 
510
# endif
-
 
511
# define rwsem_release(l, n, i)			lock_release(l, n, i)
-
 
512
#else
-
 
513
# define rwsem_acquire(l, s, t, i)		do { } while (0)
-
 
Line 514... Line -...
514
# define rwsem_acquire_nest(l, s, t, n, i)	do { } while (0)
-
 
515
# define rwsem_acquire_read(l, s, t, i)		do { } while (0)
-
 
516
# define rwsem_release(l, n, i)			do { } while (0)
506
#define rwsem_acquire(l, s, t, i)		lock_acquire_exclusive(l, s, t, NULL, i)
517
#endif
507
#define rwsem_acquire_nest(l, s, t, n, i)	lock_acquire_exclusive(l, s, t, n, i)
518
 
-
 
519
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-
 
520
# ifdef CONFIG_PROVE_LOCKING
508
#define rwsem_acquire_read(l, s, t, i)		lock_acquire_shared(l, s, t, NULL, i)
521
#  define lock_map_acquire(l)		lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_)
-
 
522
#  define lock_map_acquire_read(l)	lock_acquire(l, 0, 0, 2, 2, NULL, _THIS_IP_)
509
#define rwsem_release(l, n, i)			lock_release(l, n, i)
523
# else
-
 
524
#  define lock_map_acquire(l)		lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_)
-
 
525
#  define lock_map_acquire_read(l)	lock_acquire(l, 0, 0, 2, 1, NULL, _THIS_IP_)
-
 
526
# endif
-
 
527
# define lock_map_release(l)			lock_release(l, 1, _THIS_IP_)
-
 
Line 528... Line 510...
528
#else
510
 
529
# define lock_map_acquire(l)			do { } while (0)
511
#define lock_map_acquire(l)			lock_acquire_exclusive(l, 0, 0, NULL, _THIS_IP_)
530
# define lock_map_acquire_read(l)		do { } while (0)
512
#define lock_map_acquire_read(l)		lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_)
531
# define lock_map_release(l)			do { } while (0)
513
#define lock_map_acquire_tryread(l)		lock_acquire_shared_recursive(l, 0, 1, NULL, _THIS_IP_)