[Devel] [PATCH RHEL7 COMMIT] locking: Add LOCK_CONTENDED_RETURN

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 25 17:56:00 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.1
------>
commit 2be9326b9b38cb78dab05006822dd151df3646cf
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon May 25 17:55:59 2020 +0300

    locking: Add LOCK_CONTENDED_RETURN
    
    >From ms commit 916633a40370 "locking/rwsem: Provide down_write_killable()"
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    This ports support for down_read_killable(),
    which is a prerequisite for pernet_ops_rwsem.
    
    https://jira.sw.ru/browse/PSBM-104158
---
 include/linux/lockdep.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 1c49aac45896e..242f69bddecfe 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