Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Feb 2018 16:01:39 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329378 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201802161601.w1GG1dhx072606@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Feb 16 16:01:39 2018
New Revision: 329378
URL: https://svnweb.freebsd.org/changeset/base/329378

Log:
  Implement mutex_trylock_recursive() in the LinuxKPI.
  
  MFC after:	1 week
  Submitted by:	Johannes Lundberg <johalun0@gmail.com>
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/mutex.h

Modified: head/sys/compat/linuxkpi/common/include/linux/mutex.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/mutex.h	Fri Feb 16 15:52:28 2018	(r329377)
+++ head/sys/compat/linuxkpi/common/include/linux/mutex.h	Fri Feb 16 16:01:39 2018	(r329378)
@@ -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)
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802161601.w1GG1dhx072606>