From owner-svn-src-all@FreeBSD.ORG Mon Feb 8 07:31:06 2010 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 3E4A7106566C; Mon, 8 Feb 2010 07:31:06 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F0528FC15; Mon, 8 Feb 2010 07:31:06 +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 o187V6E8072518; Mon, 8 Feb 2010 07:31:06 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o187V5Pk072517; Mon, 8 Feb 2010 07:31:05 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201002080731.o187V5Pk072517@svn.freebsd.org> From: David Xu Date: Mon, 8 Feb 2010 07:31:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203657 - head/sys/kern 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: Mon, 08 Feb 2010 07:31:06 -0000 Author: davidxu Date: Mon Feb 8 07:31:05 2010 New Revision: 203657 URL: http://svn.freebsd.org/changeset/base/203657 Log: Set waiters flag before checking semaphore's counter, otherwise we might lose a wakeup. Tested on postgresql database server. Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Mon Feb 8 06:28:33 2010 (r203656) +++ head/sys/kern/kern_umtx.c Mon Feb 8 07:31:05 2010 (r203657) @@ -2853,6 +2853,8 @@ do_sem_wait(struct thread *td, struct _u umtxq_insert(uq); umtxq_unlock(&uq->uq_key); + suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1); + count = fuword32(__DEVOLATILE(uint32_t *, &sem->_count)); if (count != 0) { umtxq_lock(&uq->uq_key); @@ -2863,11 +2865,6 @@ do_sem_wait(struct thread *td, struct _u return (0); } - /* - * set waiters byte and sleep. - */ - suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1); - umtxq_lock(&uq->uq_key); umtxq_unbusy(&uq->uq_key); umtxq_unlock(&uq->uq_key);