summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2009-05-29 13:56:34 +0000
committerjhb <jhb@FreeBSD.org>2009-05-29 13:56:34 +0000
commitcdcee493a206829c1a3ccc94df157c9720285eb7 (patch)
tree778d8b116b84c956f481f3604b85ee7646ea031f
parent9217f2901bf3eb4d8b3a4fd833f32c26cba41164 (diff)
downloadFreeBSD-src-cdcee493a206829c1a3ccc94df157c9720285eb7.zip
FreeBSD-src-cdcee493a206829c1a3ccc94df157c9720285eb7.tar.gz
Tweak a few comments on adaptive spinning.
-rw-r--r--sys/kern/kern_mutex.c7
-rw-r--r--sys/kern/kern_rwlock.c14
2 files changed, 15 insertions, 6 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 49f9c59..17c72eb 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -399,8 +399,11 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts, const char *file,
#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)) {
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index 993acfa..cc5f4f132 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -412,8 +412,11 @@ _rw_rlock(struct rwlock *rw, const char *file, int line)
#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, uintptr_t tid, const char *file, int line)
#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);
OpenPOWER on IntegriCloud