[Devel] [PATCH RH7 5/6] locking: Add LOCK_CONTENDED_RETURN
Kirill Tkhai
ktkhai at virtuozzo.com
Fri May 22 20:03:13 MSK 2020
>From ms commit 916633a40370 "locking/rwsem: Provide down_write_killable()"
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
include/linux/lockdep.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 1c49aac45896..242f69bddecf 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -457,6 +457,18 @@ do { \
lock_acquired(&(_lock)->dep_map, _RET_IP_); \
} while (0)
+#define LOCK_CONTENDED_RETURN(_lock, try, lock) \
+({ \
+ int ____err = 0; \
+ if (!try(_lock)) { \
+ lock_contended(&(_lock)->dep_map, _RET_IP_); \
+ ____err = lock(_lock); \
+ } \
+ if (!____err) \
+ lock_acquired(&(_lock)->dep_map, _RET_IP_); \
+ ____err; \
+})
+
#else /* CONFIG_LOCK_STAT */
#define lock_contended(lockdep_map, ip) do {} while (0)
@@ -465,6 +477,9 @@ do { \
#define LOCK_CONTENDED(_lock, try, lock) \
lock(_lock)
+#define LOCK_CONTENDED_RETURN(_lock, try, lock) \
+ lock(_lock)
+
#endif /* CONFIG_LOCK_STAT */
#ifdef CONFIG_LOCKDEP
More information about the Devel
mailing list