Date: Sun, 25 Nov 2012 12:49:44 +0000 From: Attilio Rao <attilio@freebsd.org> To: Ryan Stone <rysto32@gmail.com>, John Baldwin <jhb@freebsd.org> Cc: FreeBSD Current <freebsd-current@freebsd.org> Subject: Re: Spurious witness warning when destroying spin mtx Message-ID: <CAJ-FndABZ1S4aEQW0GM_Zdyk_cb9Vq=Pur2xbcJL%2BHvnnLbWhw@mail.gmail.com> In-Reply-To: <CAJ-FndDL18oQdFZQh4AKr9NbOc2WxWJoDVjOtkjt%2Bb7w36E_kA@mail.gmail.com> References: <CAFMmRNyYccyXFh0r2jC2Q5ynYQH09SiZNguLp8X4JWSX4Lua5w@mail.gmail.com> <CAJ-FndDL18oQdFZQh4AKr9NbOc2WxWJoDVjOtkjt%2Bb7w36E_kA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Nov 24, 2012 at 3:01 PM, Attilio Rao <attilio@freebsd.org> wrote: > On Sat, Nov 24, 2012 at 3:08 AM, Ryan Stone <rysto32@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. > > Can you please show which lock triggers the panic you saw? Ryan, however I'm sure this patch would introduce a major switch in our KPI/POLA and eventually it would be a bigger work. Your patch is certainly right and I think you should commit it for the time being. For the long-term, maybe you would like to work on such a patch, rather. Attilio -- Peace can only be achieved by understanding - A. Einstein
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-FndABZ1S4aEQW0GM_Zdyk_cb9Vq=Pur2xbcJL%2BHvnnLbWhw>