cvs commit: src/sys/nfsserver nfs_srvsock.c

John Baldwin jhb at
Thu Mar 20 06:02:25 PDT 2008

On Thursday 20 March 2008 07:00:48 am Robert Watson wrote:
> On Thu, 20 Mar 2008, Doug Rabson wrote:
> >> This function should have a WITNESS check at the top of it.
> >>
> >> Can you add it?  If not I will unless you see a problem with it.
> >
> > The various WITNESS_* macros appear to be undocumented and I'm not sure
> > what they do. Perhaps it would be best if you added something.
> I usually copy and paste it from another use, such as the sleep checks for
> the MAC Framework.  When I do that, I often think to myself: wouldn't it be
> nice if we had a simple WITNESS_MAYSLEEP() macro to say "this code path may
> sleep, just do whateve ryou're going to do".

That would basically be:

	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, a_lock_im_holding_that_is_ok,

If you aren't currently holding a lock (i.e. no other locks aside from Giant 
or sx should be held) then pass NULL instead 
of "a_lock_im_holding_that_is_ok".

Basically, WITNESS_WARN() emits a warning if you hold any locks when it is 
called.  The optional lock pointer is exempt from the check (so it is ok for 
it to be held) and the flags are documented in <sys/lock.h> (they can exemmpt 
other locks or force a panic vs. just messages on the console)).

John Baldwin

More information about the cvs-src mailing list