Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Mar 2001 03:59:01 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org
Subject:   RE: cvs commit: src/sys/alpha/alpha machdep.c src/sys/alpha/incl
Message-ID:  <XFMail.010328035901.jhb@FreeBSD.org>
In-Reply-To: <200103280903.f2S93OY61544@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 28-Mar-01 John Baldwin wrote:
> jhb         2001/03/28 01:03:24 PST
> 
>   Modified files:
>     sys/alpha/alpha      machdep.c 
>     sys/alpha/include    globaldata.h 
>     sys/conf             files 
>     sys/i386/i386        machdep.c mp_machdep.c 
>     sys/i386/include     globaldata.h 
>     sys/ia64/ia64        machdep.c 
>     sys/ia64/include     globaldata.h 
>     sys/kern             kern_condvar.c kern_fork.c kern_mutex.c 
>                          kern_sx.c kern_synch.c subr_witness.c 
>     sys/sys              kernel.h lock.h mutex.h proc.h sx.h 
>   Log:
>   Rework the witness code to work with sx locks as well as mutexes.

The only really annoying bug right now is that recursing on a sx lock is not
handled by the witness code.  The sx locks themselves already do not allow
recursive exlusive locks.  However, there is no good way for detecting a
recursive shared lock.  Currently, witness will report such events as a lock
order violation.  If needed one could walk the p_sleeplocks list in the WITNESS
case to see if we already have locked this lock before, but this starts to get
ugly. :(

Unfortunately, not only was the witness code very mutex centric, it was also
very much tied to having locks only being held by one process, and making
witness completely generic requires that we push all of this state out of the
locks and into the processes.  I didn't do this fully, as I wanted to get this
working before the next millenium rolled around.  At some point I may go back
and do that as it may cut down on the memory used by locks in the non-witness
case as well as allowing us to handle recursion checks completely in the
witness code, even for shared sx locks.  This should be enough to make witness
largely ussable with sx locks for now, however.

Witness still doesn't cope well with unloading a module that contains a mutex.
As a workaround, you can just add a new order list containing just the single
lock in question.  The problem being that witness needs to have a valid name
pointer that its internal struct witness points to.  Eventually this will be
fixed using refcounts and some other h0h0 magic.

The sleep list and ignore list have been replaced.  For a lock that is to be
ignored, it simply needs to not specify LO_WITNESS in it's lock_object's
lo_flags.  For mutexes, you can do this by passing MTX_NOWITNESS to mtx_init().
For the sleep list, you specify the LO_SLEEPABLE flag in the lock_object's
lo_flags.  Note that Giant is a special hard-coded case, as is the lock passed
into witness_sleep() (they are both released during the actual process of
sleeping).

Most of the changes were all down inside the lock code itself.  The only
changes as far as users of mutexes or sx locks are concerned is that
sys/mutex.h and sys/sx.h now require sys/lock.h.

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

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




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