Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Feb 2007 10:10:05 -0800
From:      Luigi Rizzo <rizzo@icir.org>
To:        Andrew Gallatin <gallatin@cs.duke.edu>
Cc:        cvs-src@FreeBSD.org, Luigi Rizzo <luigi@FreeBSD.org>, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/arm/xscale/ixp425 ixp425_npe.c src/sys/dev/ipw if_ipw.c if_ipwvar.h src/sys/dev/isp isp_freebsd.h src/sys/dev/iwi if_iwi.c if_iwivar.h src/sys/dev/mxge if_mxge.c src/sys/kern subr_firmware.c src/sys/sys firmware.h src/sys/tools fw_stub.awk
Message-ID:  <20070221101005.A91427@xorpc.icir.org>
In-Reply-To: <17884.34420.308021.423716@grasshopper.cs.duke.edu>; from gallatin@cs.duke.edu on Wed, Feb 21, 2007 at 12:50:44PM -0500
References:  <200702151721.l1FHLWno019525@repoman.freebsd.org> <20070221121302.A20229@grasshopper.cs.duke.edu> <20070221092332.A90766@xorpc.icir.org> <17884.34420.308021.423716@grasshopper.cs.duke.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 21, 2007 at 12:50:44PM -0500, Andrew Gallatin wrote:
...
> Speaking of icky, I'm really worried about the pedantic nature of
> FreeBSD's WITNESS and "never, ever sleep while holding a mutex" dogma
> causing as many problems as it solves.  For example, iwi seems to
> simply drop its lock when loading firmware (presumably to avoid
> WITNESS squawking about holding a mutex while grabbing an sx).  This
> certainly shuts up WITNESS, but it may also introduce a race,
> especially if the linker needs to sleep and wait for the disk.

i am not sure i follow you here...
Of course when you drop the lock you risk that the underlying
data structure is manipulated (or in the worst case freed),
but usually you can avoid this with something like

	<while locked>
	sc->flags |= LEAVE_ME_ALONE
	UNLOCK
	do_something_blocking()
	LOCK
	sc->flags &= ~LEAVE_ME_ALONE
	do_something_else()
	if (sc->flags & I_AM_WAITING) {
		sc->flags &= ~I_AM_WAITING;
		wakeup(sc);
	}
	UNLOCK

while others would do

	LOCK(sc->mtx)
	while (sc->flags & LEAVE_ME_ALONE) {
		sc->flags |= I_AM_WAITING;
		msleep(sc, &sc->mtx, ...)
	}

to synchronize...

	cheers
	luigi



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