Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Mar 2008 08:47:20 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Robert Watson <rwatson@freebsd.org>
Cc:        Doug Rabson <dfr@freebsd.org>, src-committers@freebsd.org, cvs-src@freebsd.org, Alfred Perlstein <alfred@freebsd.org>, cvs-all@freebsd.org, Doug Rabson <dfr@rabson.org>
Subject:   Re: cvs commit: src/sys/nfsserver nfs_srvsock.c
Message-ID:  <200803200847.21375.jhb@freebsd.org>
In-Reply-To: <20080320105941.H38241@fledge.watson.org>
References:  <200803191233.m2JCXPRp070753@repoman.freebsd.org> <F042E351-95A3-4C9A-92AF-878CB0F93EBE@rabson.org> <20080320105941.H38241@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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,
	    "foo");

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



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