From owner-freebsd-current@FreeBSD.ORG Wed Aug 26 22:57:05 2009 Return-Path: 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 073A1106568E for ; Wed, 26 Aug 2009 22:57:05 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-fx0-f210.google.com (mail-fx0-f210.google.com [209.85.220.210]) by mx1.freebsd.org (Postfix) with ESMTP id 8CF048FC20 for ; Wed, 26 Aug 2009 22:57:04 +0000 (UTC) Received: by fxm6 with SMTP id 6so486783fxm.43 for ; Wed, 26 Aug 2009 15:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=RghxObV8CCqHc3ZuqG5OW4lm2PSNqqnmcr//n/92vW8=; b=gYguEAZlfCnrhNxOoOXbeSBsZAQ4Zbag52xROdncYoNtpBLnl16c/g3qSf7Os4xp2c AX1yoDm9TcpCX3l4vik7D3kWf/DHXbJtLDzAWzUuSQbklZRGGAxQaWYz0LMQos2Ka74C fy62+n7RUy4WqNoHb6fNktLDIqRctinWqxoSU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=xszEHDVFnxlSsqsl/3euVQR5yFawYZ7QBXPyaamWxjCbMhvI5jDiwOUxY3fKVk64M8 C/zZt3ulZo/3n9ti4QcvGDCbsRHUbwnDV3zma1yy58vu6rbAKSGTcGViD0B2pb/2Xj1c MiO4FX8vqO3Oiw1h1SN0QhFbZSygXUEgicHf8= MIME-Version: 1.0 Sender: asmrookie@gmail.com Received: by 10.223.24.87 with SMTP id u23mr6364037fab.81.1251327423674; Wed, 26 Aug 2009 15:57:03 -0700 (PDT) In-Reply-To: References: Date: Thu, 27 Aug 2009 00:57:03 +0200 X-Google-Sender-Auth: fca42a3cda7dd847 Message-ID: <3bbf2fe10908261557i286f5ec5q58eb4fec1abbfc7b@mail.gmail.com> From: Attilio Rao To: Andrew Brampton Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: [patch] rw_try_wlock does not set recursive bit when recursing X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 22:57:05 -0000 2009/8/27 Andrew Brampton : > Hi, > The following sequence of commands fails on line 4 with an assertion > that the lock is not currently held: > > 1: rw_wlock(&rw); > 2: if ( rw_try_wlock(&rw) ) > 3: rw_wunlock(&rw); > 4: rw_wunlock(&rw); > > This is because after line 3 is executed the rw lock is no longer > held. I tracked this bug down to _rw_try_wlock which correctly > increments rw_recurse, but does not set the RW_LOCK_RECURSED bit. > Without this bit the third line unlocks the lock and leaves it in a > unlocked state (when it should still be locked). Adding a line to set > this bit makes _rw_try_wlock match the code in _rw_wlock_hard. Sorry, but I really don't understand how that can be a bug. On STABLE_7, RW_LOCK_RECURSED is not used for checking if the lock is recursed or not. it just got set for improving debugging and eventually we decided to drop it for 8.0. However, for deciding if a lock is recursed or not in both STABLE_7 and HEAD we used just checking against the recursion count which is correctly handled by the function. What you describe can't be the problem. Attilio -- Peace can only be achieved by understanding - A. Einstein