Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 May 2009 13:56:34 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r193035 - head/sys/kern
Message-ID:  <200905291356.n4TDuYaP076613@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri May 29 13:56:34 2009
New Revision: 193035
URL: http://svn.freebsd.org/changeset/base/193035

Log:
  Tweak a few comments on adaptive spinning.

Modified:
  head/sys/kern/kern_mutex.c
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_mutex.c
==============================================================================
--- head/sys/kern/kern_mutex.c	Fri May 29 13:48:42 2009	(r193034)
+++ head/sys/kern/kern_mutex.c	Fri May 29 13:56:34 2009	(r193035)
@@ -399,8 +399,11 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t
 
 #ifdef ADAPTIVE_MUTEXES
 		/*
-		 * If the current owner of the lock is executing on another
-		 * CPU quit the hard path and try to spin.
+		 * The current lock owner might have started executing
+		 * on another CPU (or the lock could have changed
+		 * owners) while we were waiting on the turnstile
+		 * chain lock.  If so, drop the turnstile lock and try
+		 * again.
 		 */
 		owner = (struct thread *)(v & ~MTX_FLAGMASK);
 		if (TD_IS_RUNNING(owner)) {

Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c	Fri May 29 13:48:42 2009	(r193034)
+++ head/sys/kern/kern_rwlock.c	Fri May 29 13:56:34 2009	(r193035)
@@ -412,8 +412,11 @@ _rw_rlock(struct rwlock *rw, const char 
 
 #ifdef ADAPTIVE_RWLOCKS
 		/*
-		 * If the current owner of the lock is executing on another
-		 * CPU quit the hard path and try to spin.
+		 * The current lock owner might have started executing
+		 * on another CPU (or the lock could have changed
+		 * owners) while we were waiting on the turnstile
+		 * chain lock.  If so, drop the turnstile lock and try
+		 * again.
 		 */
 		if ((v & RW_LOCK_READ) == 0) {
 			owner = (struct thread *)RW_OWNER(v);
@@ -714,8 +717,11 @@ _rw_wlock_hard(struct rwlock *rw, uintpt
 
 #ifdef ADAPTIVE_RWLOCKS
 		/*
-		 * If the current owner of the lock is executing on another
-		 * CPU quit the hard path and try to spin.
+		 * The current lock owner might have started executing
+		 * on another CPU (or the lock could have changed
+		 * owners) while we were waiting on the turnstile
+		 * chain lock.  If so, drop the turnstile lock and try
+		 * again.
 		 */
 		if (!(v & RW_LOCK_READ)) {
 			owner = (struct thread *)RW_OWNER(v);



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