From owner-svn-src-all@FreeBSD.ORG Thu Sep 24 08:35:18 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5512A106566C; Thu, 24 Sep 2009 08:35:18 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 42E1A8FC13; Thu, 24 Sep 2009 08:35:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8O8ZI4x090124; Thu, 24 Sep 2009 08:35:18 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8O8ZIeI090122; Thu, 24 Sep 2009 08:35:18 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200909240835.n8O8ZIeI090122@svn.freebsd.org> From: Attilio Rao Date: Thu, 24 Sep 2009 08:35:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197452 - in stable/8/lib/libthr: . thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 08:35:18 -0000 Author: attilio Date: Thu Sep 24 08:35:17 2009 New Revision: 197452 URL: http://svn.freebsd.org/changeset/base/197452 Log: MFC r197445: Let fall down in the hard path (thus handling shared waiters wakeup correctly) for the shared waiters also in the rwlock held in shared mode as well, fixing possible deadlocks. Please note that this is a special condition as we want this fix in before RC2 as we assume it is critical and so it has been handled as an instant-merge. For the STABLE_7 branch, 1 week before the MFC is assumed. Approved by: re (kib) Modified: stable/8/lib/libthr/ (props changed) stable/8/lib/libthr/thread/thr_umtx.h Modified: stable/8/lib/libthr/thread/thr_umtx.h ============================================================================== --- stable/8/lib/libthr/thread/thr_umtx.h Thu Sep 24 08:16:12 2009 (r197451) +++ stable/8/lib/libthr/thread/thr_umtx.h Thu Sep 24 08:35:17 2009 (r197452) @@ -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 {