Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 2020 08:23:24 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r366879 - in stable/11/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src sys
Message-ID:  <202010200823.09K8NOcA017492@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Tue Oct 20 08:23:24 2020
New Revision: 366879
URL: https://svnweb.freebsd.org/changeset/base/366879

Log:
  MFC r347596 and r366432:
  Populate the acquire context field of a ww_mutex in the LinuxKPI.
  Bump the FreeBSD version to force recompilation of external kernel modules.
  
  Differential Revision:	https://reviews.freebsd.org/D19565
  Differential Revision:	https://reviews.freebsd.org/D26657
  Submitted by:		greg_unrelenting.technology (Greg V)
  Sponsored by:		Mellanox Technologies // NVIDIA Networking

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/ww_mutex.h
  stable/11/sys/compat/linuxkpi/common/src/linux_lock.c
  stable/11/sys/sys/param.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/ww_mutex.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/ww_mutex.h	Tue Oct 20 08:17:47 2020	(r366878)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/ww_mutex.h	Tue Oct 20 08:23:24 2020	(r366879)
@@ -45,6 +45,7 @@ struct ww_acquire_ctx {
 struct ww_mutex {
 	struct mutex base;
 	struct cv condvar;
+	struct ww_acquire_ctx *ctx;
 };
 
 #define	DEFINE_WW_CLASS(name)					\
@@ -75,7 +76,8 @@ ww_mutex_trylock(struct ww_mutex *lock)
 	return (mutex_trylock(&lock->base));
 }
 
-extern int linux_ww_mutex_lock_sub(struct ww_mutex *, int catch_signal);
+extern int linux_ww_mutex_lock_sub(struct ww_mutex *,
+    struct ww_acquire_ctx *, int catch_signal);
 
 static inline int
 ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
@@ -85,7 +87,7 @@ ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire
 	else if ((struct thread *)SX_OWNER(lock->base.sx.sx_lock) == curthread)
 		return (-EALREADY);
 	else
-		return (linux_ww_mutex_lock_sub(lock, 0));
+		return (linux_ww_mutex_lock_sub(lock, ctx, 0));
 }
 
 static inline int
@@ -96,7 +98,7 @@ ww_mutex_lock_interruptible(struct ww_mutex *lock, str
 	else if ((struct thread *)SX_OWNER(lock->base.sx.sx_lock) == curthread)
 		return (-EALREADY);
 	else
-		return (linux_ww_mutex_lock_sub(lock, 1));
+		return (linux_ww_mutex_lock_sub(lock, ctx, 1));
 }
 
 extern void linux_ww_mutex_unlock_sub(struct ww_mutex *);

Modified: stable/11/sys/compat/linuxkpi/common/src/linux_lock.c
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/src/linux_lock.c	Tue Oct 20 08:17:47 2020	(r366878)
+++ stable/11/sys/compat/linuxkpi/common/src/linux_lock.c	Tue Oct 20 08:23:24 2020	(r366879)
@@ -71,7 +71,8 @@ linux_ww_unlock(void)
 
 /* lock a mutex with deadlock avoidance */
 int
-linux_ww_mutex_lock_sub(struct ww_mutex *lock, int catch_signal)
+linux_ww_mutex_lock_sub(struct ww_mutex *lock,
+    struct ww_acquire_ctx *ctx, int catch_signal)
 {
 	struct task_struct *task;
 	struct ww_mutex_thread entry;
@@ -126,6 +127,9 @@ done:
 		if ((struct thread *)SX_OWNER(lock->base.sx.sx_lock) == NULL)
 			cv_signal(&lock->condvar);
 	}
+
+	if (retval == 0)
+		lock->ctx = ctx;
 	linux_ww_unlock();
 	return (retval);
 }
@@ -135,6 +139,7 @@ linux_ww_mutex_unlock_sub(struct ww_mutex *lock)
 {
 	/* protect ww_mutex ownership change */
 	linux_ww_lock();
+	lock->ctx = NULL;
 	sx_xunlock(&lock->base.sx);
 	/* wakeup a lock waiter, if any */
 	cv_signal(&lock->condvar);

Modified: stable/11/sys/sys/param.h
==============================================================================
--- stable/11/sys/sys/param.h	Tue Oct 20 08:17:47 2020	(r366878)
+++ stable/11/sys/sys/param.h	Tue Oct 20 08:23:24 2020	(r366879)
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1104507	/* Master, propagated to newvers */
+#define __FreeBSD_version 1104508	/* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,



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