svn commit: r329955 - stable/11/sys/compat/linuxkpi/common/include/linux
Hans Petter Selasky
hselasky at FreeBSD.org
Sun Feb 25 10:19:45 UTC 2018
Author: hselasky
Date: Sun Feb 25 10:19:44 2018
New Revision: 329955
URL: https://svnweb.freebsd.org/changeset/base/329955
Log:
MFC r329378:
Implement mutex_trylock_recursive() in the LinuxKPI.
Submitted by: Johannes Lundberg <johalun0 at gmail.com>
Sponsored by: Mellanox Technologies
Modified:
stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h Sun Feb 25 10:18:49 2018 (r329954)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/mutex.h Sun Feb 25 10:19:44 2018 (r329955)
@@ -77,6 +77,21 @@ typedef struct mutex {
!!sx_try_xlock(&(_m)->sx); \
})
+enum mutex_trylock_recursive_enum {
+ MUTEX_TRYLOCK_FAILED = 0,
+ MUTEX_TRYLOCK_SUCCESS = 1,
+ MUTEX_TRYLOCK_RECURSIVE = 2,
+};
+
+static inline __must_check enum mutex_trylock_recursive_enum
+mutex_trylock_recursive(struct mutex *lock)
+{
+ if (unlikely(sx_xholder(&lock->sx) == curthread))
+ return (MUTEX_TRYLOCK_RECURSIVE);
+
+ return (mutex_trylock(lock));
+}
+
#define mutex_init(_m) \
linux_mutex_init(_m, mutex_name(#_m), SX_NOWITNESS)
More information about the svn-src-all
mailing list