summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2014-09-10 14:31:39 -0400
committerBen Hutchings <ben@decadent.org.uk>2015-12-30 02:26:00 +0000
commit377ace8bdcb36a3961b894f20090d8fae1197872 (patch)
tree28e98a19c9b24dc85a8deafd97d0e7062e8954b5 /include
parentb1fa852672fb1ea4b0e34bfa1136bb65dba66151 (diff)
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 <peter@hurleysoftware.com> Acked-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include')
-rw-r--r--include/linux/lockdep.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index b6a56e37284c..8b9bbf1d5b6e 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -342,6 +342,9 @@ extern void lockdep_trace_alloc(gfp_t mask);
#define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0)
#define lockdep_assert_held(l) WARN_ON(debug_locks && !lockdep_is_held(l))
+#define lockdep_assert_held_once(l) do { \
+ WARN_ON_ONCE(debug_locks && !lockdep_is_held(l)); \
+ } while (0)
#else /* !LOCKDEP */
@@ -362,6 +365,7 @@ static inline void lockdep_on(void)
# define lockdep_trace_alloc(g) do { } while (0)
# define lockdep_init() do { } while (0)
# define lockdep_info() do { } while (0)
+
# define lockdep_init_map(lock, name, key, sub) \
do { (void)(name); (void)(key); } while (0)
# define lockdep_set_class(lock, key) do { (void)(key); } while (0)
@@ -391,6 +395,7 @@ struct lock_class_key { };
#define lockdep_depth(tsk) (0)
#define lockdep_assert_held(l) do { } while (0)
+#define lockdep_assert_held_once(l) do { (void)(l); } while (0)
#endif /* !LOCKDEP */