PERFORCE change 95729 for review
John Baldwin
jhb at freebsd.org
Fri Apr 21 02:30:08 UTC 2006
On Thursday 20 April 2006 05:54 pm, John Birrell wrote:
> http://perforce.freebsd.org/chv.cgi?CH=95729
>
> Change 95729 by jb at jb_freebsd2 on 2006/04/20 21:53:46
>
> Use macros to translate Solaris kmem_zalloc(), kmem_alloc() and
> kmem_free() calls into their FreeBSD equivalents. This turns out to
> be a neat way to port their code.
>
> Most memory allocations in this driver occur with one or more
> mutex/es locked. Since dtrace is part of a released product, I'm
> porting this on the assumption that the locking strategy works.
> With witness enabled, I can't have it downgrade a M_WAITOK call
> to a M_NOWAIT call just because it thinks it's a not a good idea
> to sleep with locks held. For this code, we need to do that and
> we can't afford to fail because the thing that we might be trying
> to trace is the low memory situation. We might not be too
> successful, but we need to try. Anyway... that's why the mutexes
> are initialised with M_NOWITNESS.
This is because FreeBSD mutexes != Solaris mutexes. You may or may not end up
with arbitrary panics and deadlocks if the malloc() actually blocks. You
could use an sx(9) instead and just use sx_xlock() and sx_xunlock() which will
be safe to hold across a blocking malloc().
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the p4-projects
mailing list