Re: Spurious witness warning when destroying spin mtx

From: John Baldwin <jhb_at_freebsd.org>
Date: Mon, 14 Jan 2013 14:03:45 -0500
On Saturday, November 24, 2012 10:01:39 am Attilio Rao wrote:
> On Sat, Nov 24, 2012 at 3:08 AM, Ryan Stone <rysto32_at_gmail.com> 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
Received on Mon Jan 14 2013 - 18:37:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:34 UTC