From owner-freebsd-current@FreeBSD.ORG  Wed Feb  3 23:43:37 2010
Return-Path: <owner-freebsd-current@FreeBSD.ORG>
Delivered-To: freebsd-current@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8F42F106566C;
	Wed,  3 Feb 2010 23:43:37 +0000 (UTC)
	(envelope-from giovanni.trematerra@gmail.com)
Received: from mail-fx0-f226.google.com (mail-fx0-f226.google.com
	[209.85.220.226])
	by mx1.freebsd.org (Postfix) with ESMTP id E7E7F8FC13;
	Wed,  3 Feb 2010 23:43:36 +0000 (UTC)
Received: by fxm26 with SMTP id 26so282023fxm.13
	for <multiple recipients>; Wed, 03 Feb 2010 15:43:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:received:in-reply-to:references
	:date:message-id:subject:from:to:cc:content-type;
	bh=ONXzQUyVigQUAxxj1P+nHWFA+xST/O6ptwshE8h5xuI=;
	b=CmViG9JrQpq7hHVzUyiQRK7jPTb1sAILjq+uFesa7OzA/15O8ylxREMUBljJTAmy6H
	hDoPFYOLZMAdpf1m8GfKeAFUHRRdZBrAH2NOg/po0P7oldZhLFIh9OGpVgLsMSkOZVGZ
	GbXV/ELv5KmXqcBNICiw6sMLvibO3ftZFVyXo=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type;
	b=owecXU911Pzke+9aPQtfw8PFZxcmzmHxB7UcYdijENG9LjLwuafwOjSBUZMmOyEKrT
	nFMqO/Y1JZ0qKDA1kGffSzYR+VyJEYTpU4F6xYIgpsRgm8NuQztdWAJOjhoPBYXkKrlS
	A/vHwej8T1J4Gm9uF/A6ixirNNU0/7My4QSfA=
MIME-Version: 1.0
Received: by 10.223.4.25 with SMTP id 25mr277264fap.38.1265240616005; Wed, 03 
	Feb 2010 15:43:36 -0800 (PST)
In-Reply-To: <179b97fb1002031002g617aee35uec79e3367b2ff7a5@mail.gmail.com>
References: <B4F940BE-04BD-4ACC-B686-21D61423D236@lakerest.net>
	<20100128201520.6a114290@ernst.jennejohn.org>
	<117532D7-75B9-4BE8-A8B6-0A6761064B92@lakerest.net>
	<4e6cba831001290744m6067691ct489c61fe9cd28502@mail.gmail.com>
	<179b97fb1001291212p5b0829f2pea28ab36a85751cf@mail.gmail.com>
	<4e6cba831002011404h1b6b893cj2390bf0a7560a7f2@mail.gmail.com>
	<179b97fb1002011424p4a799ff6t8f6b39e6f4b66828@mail.gmail.com>
	<4e6cba831002022320u2bd5f325m6564556a1abcf4c5@mail.gmail.com>
	<179b97fb1002031002g617aee35uec79e3367b2ff7a5@mail.gmail.com>
Date: Thu, 4 Feb 2010 00:43:35 +0100
Message-ID: <4e6cba831002031543r391ba4c7m620868fe9cc044a8@mail.gmail.com>
From: Giovanni Trematerra <giovanni.trematerra@gmail.com>
To: Brandon Gooch <jamesbrandongooch@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Cc: Attilio Rao <attilio@freebsd.org>,
	FreeBSD Current <freebsd-current@freebsd.org>,
	Randall Stewart <rrs@lakerest.net>
Subject: Re: A strange thing with yesterday's head..
X-BeenThere: freebsd-current@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Discussions about the use of FreeBSD-current
	<freebsd-current.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>, 
	<mailto:freebsd-current-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current>
List-Post: <mailto:freebsd-current@freebsd.org>
List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>,
	<mailto:freebsd-current-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 03 Feb 2010 23:43:37 -0000

> Just tried it again (a few times) at r203430, with similar results.

Hi Brandon,
did you update -STABLE? I meant -CURRENT!
Anyway, if you are updating -STABLE, please try the patch below. I
don't know if it applies on -STABLE, let me know.

Thanks for your time.

--
Gianni

--- head/sys/kern/kern_umtx.c	2010/01/10 09:31:57	201991
+++ head/sys/kern/kern_umtx.c	2010/02/03 03:56:32	203414
@@ -2526,6 +2526,12 @@
 		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);
@@ -2658,6 +2664,12 @@
 		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);