MTX_DEF versus MTX_SPIN

Andriy Gapon avg at icyb.net.ua
Wed Nov 3 17:09:26 UTC 2010


on 03/11/2010 19:04 mdf at FreeBSD.org said the following:
> On Wed, Nov 3, 2010 at 9:42 AM, Andriy Gapon <avg at icyb.net.ua> wrote:
>> on 03/11/2010 18:27 mdf at FreeBSD.org said the following:
>>> It's not clear to me from the man pages (perhaps I didn't look at the
>>> right one?) in which environments I need a spinlock.  For example, I
>>> wouldn't think it's safe to use a MTX_DEF in a hard interrupt handler
>>> (i.e one that was registered with BUS_SETUP_INTR), but I see some code
>>> lying around here that does it and nothing I'm aware of has broken.
>>
>> Such a handler runs in an interrupt thread.
>> The "harder" interrupt handler is called interrupt filter in FreeBSD terminology.
>>  I think that it was formerly known as fast interrupt.
> 
> So a MTX_DEF is okay in that environment?

Yes, I think so.

> What would "best practices" be considered for what code should be run
> in the interrupt handler versus a soft interrupt?

Sorry for not going into details, but I personally think that there is no reason
to use soft interrupts.  If you can do everything in interrupt handler (i.e. on
interrupt threads), then that should be all you need.

-- 
Andriy Gapon


More information about the freebsd-current mailing list