svn commit: r203694 - stable/7/sys/kern

David Xu davidxu at FreeBSD.org
Tue Feb 9 01:19:10 UTC 2010


Author: davidxu
Date: Tue Feb  9 01:19:10 2010
New Revision: 203694
URL: http://svn.freebsd.org/changeset/base/203694

Log:
  MFC r203414:
  After busied the lock, re-read state word before checking waiters flag,
  otherwise, the waiters bit may not be set and a wakeup is lost.
  
  Approved by:	re (kib)

Modified:
  stable/7/sys/kern/kern_umtx.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/kern/kern_umtx.c
==============================================================================
--- stable/7/sys/kern/kern_umtx.c	Tue Feb  9 00:38:40 2010	(r203693)
+++ stable/7/sys/kern/kern_umtx.c	Tue Feb  9 01:19:10 2010	(r203694)
@@ -2463,6 +2463,12 @@ do_rw_rdlock(struct thread *td, struct u
 		umtxq_busy(&uq->uq_key);
 		umtxq_unlock(&uq->uq_key);
 
+		/*
+		 * re-read the state, in case it changed between the try-lock above
+		 * and the check below
+		 */
+		state = fuword32(__DEVOLATILE(int32_t *, &rwlock->rw_state));
+
 		/* set read contention bit */
 		while ((state & wrflags) && !(state & URWLOCK_READ_WAITERS)) {
 			oldstate = casuword32(&rwlock->rw_state, state, state | URWLOCK_READ_WAITERS);
@@ -2595,6 +2601,12 @@ do_rw_wrlock(struct thread *td, struct u
 		umtxq_busy(&uq->uq_key);
 		umtxq_unlock(&uq->uq_key);
 
+		/*
+		 * re-read the state, in case it changed between the try-lock above
+		 * and the check below
+		 */
+		state = fuword32(__DEVOLATILE(int32_t *, &rwlock->rw_state));
+
 		while (((state & URWLOCK_WRITE_OWNER) || URWLOCK_READER_COUNT(state) != 0) &&
 		       (state & URWLOCK_WRITE_WAITERS) == 0) {
 			oldstate = casuword32(&rwlock->rw_state, state, state | URWLOCK_WRITE_WAITERS);


More information about the svn-src-all mailing list