From owner-svn-src-all@freebsd.org Wed Mar 16 22:12:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84470AD35BE; Wed, 16 Mar 2016 22:12:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 65BBA662; Wed, 16 Mar 2016 22:12:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 56076B918; Wed, 16 Mar 2016 18:12:22 -0400 (EDT) From: John Baldwin To: Bryan Drewery Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296947 - head/share/man/man9 Date: Wed, 16 Mar 2016 15:12:20 -0700 Message-ID: <1525892.cfDzejblxM@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <201603161839.u2GIdm5C072960@repo.freebsd.org> References: <201603161839.u2GIdm5C072960@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 16 Mar 2016 18:12:22 -0400 (EDT) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 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: Wed, 16 Mar 2016 22:12:23 -0000 On Wednesday, March 16, 2016 06:39:48 PM Bryan Drewery wrote: > Author: bdrewery > Date: Wed Mar 16 18:39:48 2016 > New Revision: 296947 > URL: https://svnweb.freebsd.org/changeset/base/296947 > > Log: > Remove incorrect BUGS entry about asserting lock not held. > > For non-WITNESS< assertion support for SA_UNLOCKED was added in r125421 and > made to panic in r126316. > > MFC after: 1 week Eh, how can this possibly work? That is, suppose I have this code: sx_slock(&foo); sx_assert(&foo, SA_UNLOCKED); How does that safely work without WITNESS? It needs to not panic in the case that some other thread does sx_slock(&foo). In fact, the comment (modulo the spelling nit) says this explicitly: case SA_UNLOCKED: #ifdef WITNESS witness_assert(&sx->lock_object, what, file, line); #else /* * If we hold an exclusve lock fail. We can't * reliably check to see if we hold a shared lock or * not. */ if (sx_xholder(sx) == curthread) panic("Lock %s exclusively locked @ %s:%d\n", sx->lock_object.lo_name, file, line); #endif break; You could perhaps reword the bug to say that SA_UNLOCKED will panic if the lock is exclusively locked in the non-WITNESS case, but will fail to panic if the thread holds a shared lock. The wording in rwlock(9) is better than sx(9) though it should mention that RA_UNLOCKED can detect a write lock. That wording could then be used in sx(9). -- John Baldwin