Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Sep 2000 17:28:49 -0700 (PDT)
From:      John Baldwin <jhb@pike.osd.bsdi.com>
To:        alpha@FreeBSD.org
Subject:   Mutex's aren't recursing
Message-ID:  <200009120028.RAA71076@pike.osd.bsdi.com>

next in thread | raw e-mail | index | archive | help
Hmm, well, after debugging some, it seems that the mutexes on the alpha are
broken wrt recursion.  To see the code I'm using, grab the patchset
http://www.FreeBSD.org/~jhb/patches/alpha.ithreads.patch.  The code in
question are the mtx_enter and mtx_enter_hard functions in
sys/alpha/include/mutex.h and sys/alpha/alpha/syncy_machdep.c, respectively.
The problem seems to be that when we recurse on a lock, we aren't marking the
lock as recursed, and we aren't incrementing the recursion count.  However,
the code we are using to do this is almost exactly the same between i386
and alpha (and it works on i386).  As a result, when the "inner" function
releases Giant, it doesn't see that Giant is recursed, so it releases it
directly.  When the "outer" function then releases Giant, it is already free,
resulting in an assertion failure if INVARIANTS is on, or in a panic later
on as reported by other people on here.

The following snippet of KTR output show's Giant being acquired twice but
the recursion field (`r') staying at zero:

590 0:019738556 cpu0 machine/mutex.h.511        REL Giant [0xfffffc0000666170] at ../../alpha/alpha/interrupt.c:123 r=0
589 0:019685941 cpu0 machine/mutex.h.472        GOT Giant [0xfffffc0000666170] at ../../alpha/alpha/interrupt.c:121 r=0
588 0:019681066 cpu0 ../../alpha/alpha/interrupt.c.115  clock interrupt
587 0:019665286 cpu0 machine/mutex.h.472        GOT Giant [0xfffffc0000666170] at ../../alpha/alpha/ipl_funcs.c:138 r=0
586 0:019611469 cpu0 machine/mutex.h.511        REL malloc [0xfffffc000065f650] at ../../kern/kern_malloc.c:283 r=0
585 0:019563381 cpu0 machine/mutex.h.472        GOT malloc [0xfffffc000065f650] at ../../kern/kern_malloc.c:157 r=0

I've stared at the mutex code in question but don't see where it is
breaking.  Anyone else see anything that might be wrong?

-- 

John Baldwin <jhb@bsdi.com> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.cslab.vt.edu/~jobaldwi/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-alpha" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009120028.RAA71076>