Skip to contentSkip to conversation

locking: Add WARN_ON_ONCE lock assertion

PATCH In review Peter Hurley 3 participants 5 messages Sep 10, 2014 – Sep 17, 2014 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

cc Greg Kroah-Hartman <[email protected]>
---
 include/linux/lockdep.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/lockdep.h +5 -0
index 008388f9..64c7425 100644
@@ -362,6 +362,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 /* !CONFIG_LOCKDEP */
@@ -412,6 +416,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)
 
Signature · 1 line
2.1.0
#2 lore raw
Quoted 11 lines · Ingo Molnar
Quoted 6 lines · Peter Hurley

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.

cc Greg Kroah-Hartman <[email protected]>

Any objection for me taking this through the TTY tree due to the dependancies on future tty patches that use the function in this patch?

thanks,

greg k-h

#3 lore raw
Quoted 8 lines · Greg Kroah-Hartman
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Peter Hurley

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.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
cc Greg Kroah-Hartman <[email protected]>

Any objection for me taking this through the TTY tree due to the dependancies on future tty patches that use the function in this patch?

Now that the patch is correct I have no objection whatsoever, feel free!

Thanks,

Ingo

#4 lore raw
Quoted 14 lines · Ingo Molnar
Quoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Ingo Molnar
Quoted 6 lines · Peter Hurley

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.

cc Greg Kroah-Hartman <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Any objection for me taking this through the TTY tree due to the dependancies on future tty patches that use the function in this patch?

Now that the patch is correct I have no objection whatsoever, feel free!

Thanks, will do.

greg k-h