tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: What's an "MPSAFE" driver need to do?



On Thu, Feb 28, 2013 at 02:29:11AM -0500, Mouse wrote:
> [...]
> Well, assuming rwlock(9) is considered a subset of mutex(9) for the
> purposes of that sentence, I then have to ask, what else is there?
> spl(9), the traditional way, specifically calls out that those routines
> work on only the CPU they're executed on (which is what I'd expect,
> given what they have traditionally done - but, I gather from the
> manpage, no longer do).
> 
> This then leads me to wonder how a driver can _not_ be MPSAFE, since
> the old way doesn't/can't actually work and the new way is MPSAFE.

A driver not marked MPSAFE will be entered (especially
its interrupt routine, but also from upper layers) with
kernel_lock held. This is what makes spl(9) still work.
In order to convert a driver using spl(9)-style calls, you have to replace
spl(9) calls with a mutex of the equivalent IPL level (a rwlock won't work
for this as it can't be used in interrupt routines, only thread context).

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index