aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/lockdep.h
diff options
context:
space:
mode:
authorMichel Lespinasse <walken@google.com>2013-07-08 17:23:49 -0400
committerIngo Molnar <mingo@kernel.org>2013-07-12 07:51:18 -0400
commita51805efae5dda0da66f79268ffcf0715f9dbea4 (patch)
treea97a5193a8824fcea0aa7224258587b74e8940e0 /include/linux/lockdep.h
parent1b375dc30710180c4b88cc59caba6e3481ec5c8b (diff)
lockdep: Introduce lock_acquire_exclusive()/shared() helper macros
In lockdep.h, the spinlock/mutex/rwsem/rwlock/lock_map acquire macros have different definitions based on the value of CONFIG_PROVE_LOCKING. We have separate ifdefs for each of these definitions, which seems redundant. Introduce lock_acquire_{exclusive,shared,shared_recursive} helpers which will have different definitions based on CONFIG_PROVE_LOCKING. Then all other helper macros can be defined based on the above ones, which reduces the amount of ifdefined code. Signed-off-by: Michel Lespinasse <walken@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Andi Kleen <ak@linux.intel.com> Cc: "Paul E. McKenney" <paulmck@us.ibm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/20130708212350.6DD1931C15E@corp2gmr1-1.hot.corp.google.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/lockdep.h')
-rw-r--r--include/linux/lockdep.h92
1 files changed, 23 insertions, 69 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index f1e877b79ed8..cfc2f119779a 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -365,7 +365,7 @@ extern void lockdep_trace_alloc(gfp_t mask);
365 365
366#define lockdep_recursing(tsk) ((tsk)->lockdep_recursion) 366#define lockdep_recursing(tsk) ((tsk)->lockdep_recursion)
367 367
368#else /* !LOCKDEP */ 368#else /* !CONFIG_LOCKDEP */
369 369
370static inline void lockdep_off(void) 370static inline void lockdep_off(void)
371{ 371{
@@ -479,82 +479,36 @@ static inline void print_irqtrace_events(struct task_struct *curr)
479 * on the per lock-class debug mode: 479 * on the per lock-class debug mode:
480 */ 480 */
481 481
482#ifdef CONFIG_DEBUG_LOCK_ALLOC 482#ifdef CONFIG_PROVE_LOCKING
483# ifdef CONFIG_PROVE_LOCKING 483 #define lock_acquire_exclusive(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i)
484# define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) 484 #define lock_acquire_shared(l, s, t, n, i) lock_acquire(l, s, t, 1, 2, n, i)
485# define spin_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i) 485 #define lock_acquire_shared_recursive(l, s, t, n, i) lock_acquire(l, s, t, 2, 2, n, i)
486# else
487# define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
488# define spin_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, NULL, i)
489# endif
490# define spin_release(l, n, i) lock_release(l, n, i)
491#else 486#else
492# define spin_acquire(l, s, t, i) do { } while (0) 487 #define lock_acquire_exclusive(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i)
493# define spin_release(l, n, i) do { } while (0) 488 #define lock_acquire_shared(l, s, t, n, i) lock_acquire(l, s, t, 1, 1, n, i)
489 #define lock_acquire_shared_recursive(l, s, t, n, i) lock_acquire(l, s, t, 2, 1, n, i)
494#endif 490#endif
495 491
496#ifdef CONFIG_DEBUG_LOCK_ALLOC 492#define spin_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
497# ifdef CONFIG_PROVE_LOCKING 493#define spin_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i)
498# define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) 494#define spin_release(l, n, i) lock_release(l, n, i)
499# define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 2, NULL, i)
500# else
501# define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
502# define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 1, NULL, i)
503# endif
504# define rwlock_release(l, n, i) lock_release(l, n, i)
505#else
506# define rwlock_acquire(l, s, t, i) do { } while (0)
507# define rwlock_acquire_read(l, s, t, i) do { } while (0)
508# define rwlock_release(l, n, i) do { } while (0)
509#endif
510 495
511#ifdef CONFIG_DEBUG_LOCK_ALLOC 496#define rwlock_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
512# ifdef CONFIG_PROVE_LOCKING 497#define rwlock_acquire_read(l, s, t, i) lock_acquire_shared_recursive(l, s, t, NULL, i)
513# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) 498#define rwlock_release(l, n, i) lock_release(l, n, i)
514# define mutex_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i)
515# else
516# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
517# define mutex_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i)
518# endif
519# define mutex_release(l, n, i) lock_release(l, n, i)
520#else
521# define mutex_acquire(l, s, t, i) do { } while (0)
522# define mutex_acquire_nest(l, s, t, n, i) do { } while (0)
523# define mutex_release(l, n, i) do { } while (0)
524#endif
525 499
526#ifdef CONFIG_DEBUG_LOCK_ALLOC 500#define mutex_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
527# ifdef CONFIG_PROVE_LOCKING 501#define mutex_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i)
528# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) 502#define mutex_release(l, n, i) lock_release(l, n, i)
529# define rwsem_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i) 503
530# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 2, NULL, i) 504#define rwsem_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i)
531# else 505#define rwsem_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i)
532# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i) 506#define rwsem_acquire_read(l, s, t, i) lock_acquire_shared(l, s, t, NULL, i)
533# define rwsem_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i)
534# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 1, NULL, i)
535# endif
536# define rwsem_release(l, n, i) lock_release(l, n, i) 507# define rwsem_release(l, n, i) lock_release(l, n, i)
537#else
538# define rwsem_acquire(l, s, t, i) do { } while (0)
539# define rwsem_acquire_nest(l, s, t, n, i) do { } while (0)
540# define rwsem_acquire_read(l, s, t, i) do { } while (0)
541# define rwsem_release(l, n, i) do { } while (0)
542#endif
543 508
544#ifdef CONFIG_DEBUG_LOCK_ALLOC 509#define lock_map_acquire(l) lock_acquire_exclusive(l, 0, 0, NULL, _THIS_IP_)
545# ifdef CONFIG_PROVE_LOCKING 510#define lock_map_acquire_read(l) lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_)
546# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_)
547# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 2, NULL, _THIS_IP_)
548# else
549# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_)
550# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 1, NULL, _THIS_IP_)
551# endif
552# define lock_map_release(l) lock_release(l, 1, _THIS_IP_) 511# define lock_map_release(l) lock_release(l, 1, _THIS_IP_)
553#else
554# define lock_map_acquire(l) do { } while (0)
555# define lock_map_acquire_read(l) do { } while (0)
556# define lock_map_release(l) do { } while (0)
557#endif
558 512
559#ifdef CONFIG_PROVE_LOCKING 513#ifdef CONFIG_PROVE_LOCKING
560# define might_lock(lock) \ 514# define might_lock(lock) \