Embedding a vnode type to its interlock mutex type

John Baldwin jhb at FreeBSD.org
Mon Aug 18 11:38:16 PDT 2003


On 18-Aug-2003 Bruce M Simpson wrote:
> On Mon, Aug 18, 2003 at 04:13:26PM +0900, Seigo Tanimura wrote:
>> In short: A vnode should embed its type name (VREG, VCHR, etc.) in the
>> type of the interlock mutex to avoid a false LOR alarm by Witness.
> 
> I think I may have run into something similar with VM mutexes, but need
> to sit down and perform more in-depth testing to be sure about this.
> 
> It does appear as though WITNESS only checks the name of the mutex, not
> the address of the mutex, which would presumably be a suitable key to
> differentiate them uniquely.

This is intentional.   Assume I have a lock A and two processes P1 and
P2 each with a mutex.  Now assume the following code paths:

foo(P)
{
        ...
        lock(A);
        lock(P->p_mtx);
        ...
}

bar(P)
{
        ...
        lock(P->p_mtx);
        lock(A)
        ...
}

And assume the following is executed:

        foo(P1)
        bar(P2)

Should that be a lock order reversal?  I think it should be, because
bar() might be called on P1 later or foo() on P2.  If you only use
lock addresses, then witness will not catch that reversal.  Witness
intentionally defines orders between groups of locks.  Note that
you can provide witness with a different name besides the individual
mutex name via the 3rd argument to mtx_init().  See the MTX_NETWORK_LOCK
for example which is used as the class for all network driver locks.

-- 

John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


More information about the freebsd-arch mailing list