Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Oct 2004 11:46:14 -0500 (EST)
From:      Sam <sah@softcardsystems.com>
To:        Brian Fundakowski Feldman <green@freebsd.org>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: 6.0 Witness squawk
Message-ID:  <Pine.LNX.4.60.0410251126010.29901@athena>
In-Reply-To: <20041025152615.GQ1072@green.homeunix.org>
References:  <Pine.LNX.4.60.0410251037540.29901@athena> <20041025152615.GQ1072@green.homeunix.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> On Mon, Oct 25, 2004 at 11:11:13AM -0500, Sam wrote:
>> Hello,
>>
>> I'm almost finished porting my AoE (ATA over Ethernet)
>> driver to 6.0 and have a question about a complaint witness
>> is making.
>>
>> In general, is it ok to sleep with a mutex held?
>>
>> Specifically, it works like this in the driver.
>> Each device struct has a mutex for guarding
>> operations on it.  Discovering devices is a two
>> step process.  First the device must respond to
>> an AoE Query command, then it must respond to
>> an ATA identify command.  On the response to
>> the latter, I grab the device mutex, examine
>> the response and call disk_alloc() and disk_create().
>>
>> Both of these functions call malloc with M_WAITOK,
>> the latter triggers the witness message.
>>
>> In my situation, I don't really mind if I sleep
>> with the mutex since I can't do any useful work
>> with the device anyway.
>>
>> This does leave the possibility that the netisr
>> for AoE could sleep.
>>
>> Thoughts?
>
> If you can't do any useful work, why do you have the mutex?  Leave
> the mutex operations for when exclusivity _is_necessary_, after the
> major parts of initialization.  No, it's not okay to sleep with a
> mutex held -- it must be dropped a la msleep/cv/whatever.

There are three entry points into the driver.  1) The disk
layer 2) the netisr routine 3) the rexmit timer.  The mutex
is to keep them from stepping on each other.  At this stage,
the rexmit timer is active.

I'll hack in some state so I can release the mutex.  Thanks
for your helpful response.

Sam



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