From owner-freebsd-current@FreeBSD.ORG Mon Jan 14 19:37:14 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5116862E; Mon, 14 Jan 2013 19:37:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 2874B34E; Mon, 14 Jan 2013 19:37:14 +0000 (UTC) Received: from pakbsde14.localnet (unknown [38.105.238.108]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 7C0C3B963; Mon, 14 Jan 2013 14:37:10 -0500 (EST) From: John Baldwin To: attilio@freebsd.org Subject: Re: Spurious witness warning when destroying spin mtx Date: Mon, 14 Jan 2013 14:03:45 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p22; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201301141403.45905.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 14 Jan 2013 14:37:13 -0500 (EST) Cc: FreeBSD Current , Ryan Stone X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 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: Mon, 14 Jan 2013 19:37:14 -0000 On Saturday, November 24, 2012 10:01:39 am Attilio Rao wrote: > On Sat, Nov 24, 2012 at 3:08 AM, Ryan Stone wrote: > > Today I saw a spurious witness warning for "acquiring duplicate lock of > > same type". The root cause is that when running mtx_destroy on a spinlock > > that is held by the current thread, mtx_destroy calls spinlock_exit() > > before calling WITNESS_UNLOCK, which opens up a window in which the CPU can > > be interrupted and attempt to acquire another spinlock of the same type as > > the one being destroyed. This patch should fix it: > > I seriously wonder why right now we don't assume the lock is unheld. > There are likely historically reasons for that, but I would like to > know which one are those and eventually fix them out. > FWIK, all the other locking primitives assume the lock is already > unheld when destroying and I think it would be good to have that for > mutexes as well. That is simply behavior we inherited from BSD/OS. I didn't find it all that useful so all of the other locking primitives I've added since then have not had this behavior. -- John Baldwin