From f0f28197a78cc6c72ed3eb03f7081d18084efa2f Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Wed, 10 Sep 2014 14:31:39 -0400 Subject: [PATCH] locking: Add WARN_ON_ONCE lock assertion commit 9a37110d20c95d1ebf6c04881177fe8f62831db2 upstream. An interface may need to assert a lock invariant and not flood the system logs; add a lockdep helper macro equivalent to lockdep_assert_held() which only WARNs once. Signed-off-by: Peter Hurley Acked-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman Signed-off-by: Luis Henriques --- include/linux/lockdep.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index f1e877b79ed8..0bdb3e0d80fa 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -363,6 +363,10 @@ extern void lockdep_trace_alloc(gfp_t mask); WARN_ON(debug_locks && !lockdep_is_held(l)); \ } while (0) +#define lockdep_assert_held_once(l) do { \ + WARN_ON_ONCE(debug_locks && !lockdep_is_held(l)); \ + } while (0) + #define lockdep_recursing(tsk) ((tsk)->lockdep_recursion) #else /* !LOCKDEP */ @@ -413,6 +417,7 @@ struct lock_class_key { }; #define lockdep_depth(tsk) (0) #define lockdep_assert_held(l) do { (void)(l); } while (0) +#define lockdep_assert_held_once(l) do { (void)(l); } while (0) #define lockdep_recursing(tsk) (0)