Skip to content

Commit 9a37110

Browse files
peterhurleygregkh
authored andcommitted
locking: Add WARN_ON_ONCE lock assertion
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>
1 parent 93b8877 commit 9a37110

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/linux/lockdep.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ extern void lockdep_trace_alloc(gfp_t mask);
362362
WARN_ON(debug_locks && !lockdep_is_held(l)); \
363363
} while (0)
364364

365+
#define lockdep_assert_held_once(l) do { \
366+
WARN_ON_ONCE(debug_locks && !lockdep_is_held(l)); \
367+
} while (0)
368+
365369
#define lockdep_recursing(tsk) ((tsk)->lockdep_recursion)
366370

367371
#else /* !CONFIG_LOCKDEP */
@@ -412,6 +416,7 @@ struct lock_class_key { };
412416
#define lockdep_depth(tsk) (0)
413417

414418
#define lockdep_assert_held(l) do { (void)(l); } while (0)
419+
#define lockdep_assert_held_once(l) do { (void)(l); } while (0)
415420

416421
#define lockdep_recursing(tsk) (0)
417422

0 commit comments

Comments
 (0)