Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Sep 2009 21:40:02 GMT
From:      dfilter@FreeBSD.ORG (dfilter service)
To:        freebsd-threads@FreeBSD.org
Subject:   Re: threads/135673: commit references a PR
Message-ID:  <200909232140.n8NLe26N069252@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR threads/135673; it has been noted by GNATS.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: threads/135673: commit references a PR
Date: Wed, 23 Sep 2009 21:39:10 +0000 (UTC)

 Author: attilio
 Date: Wed Sep 23 21:38:57 2009
 New Revision: 197445
 URL: http://svn.freebsd.org/changeset/base/197445
 
 Log:
   rwlock implemented from libthr need to fall through the 'hard path' and
   query umtx also if the shared waiters bit is set on a shared lock.
   The writer starvation avoidance technique, infact, can lead to shared
   waiters on a shared lock which can bring to a missed wakeup and thus
   to a deadlock if the right bit is not checked (a notable case is the
   writers counterpart to be handled through expired timeouts).
   
   Fix that by checking for the shared waiters bit also when unlocking the
   shared locks.
   
   That bug was causing a reported MySQL deadlock.
   Many thanks go to Nick Esborn and his employer DesertNet which provided
   time and machines to identify and fix this issue.
   
   PR:		thread/135673
   Reported by:	Nick Esborn <nick at desert dot net>
   Tested by:	Nick Esborn <nick at desert dot net>
   Reviewed by:	jeff
 
 Modified:
   head/lib/libthr/thread/thr_umtx.h
 
 Modified: head/lib/libthr/thread/thr_umtx.h
 ==============================================================================
 --- head/lib/libthr/thread/thr_umtx.h	Wed Sep 23 20:49:14 2009	(r197444)
 +++ head/lib/libthr/thread/thr_umtx.h	Wed Sep 23 21:38:57 2009	(r197445)
 @@ -171,8 +171,11 @@ _thr_rwlock_unlock(struct urwlock *rwloc
  		for (;;) {
  			if (__predict_false(URWLOCK_READER_COUNT(state) == 0))
  				return (EPERM);
 -			if (!((state & URWLOCK_WRITE_WAITERS) && URWLOCK_READER_COUNT(state) == 1)) {
 -				if (atomic_cmpset_rel_32(&rwlock->rw_state, state, state-1))
 +			if (!((state & (URWLOCK_WRITE_WAITERS |
 +			    URWLOCK_READ_WAITERS)) &&
 +			    URWLOCK_READER_COUNT(state) == 1)) {
 +				if (atomic_cmpset_rel_32(&rwlock->rw_state,
 +				    state, state-1))
  					return (0);
  				state = rwlock->rw_state;
  			} else {
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 



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