freebsd-nq/sys
Bosko Milekic d113d3857e In m_mballoc_wait(), drop the mmbfree mutex lock prior to calling
m_reclaim() and re-acquire it when m_reclaim() returns. This means that
we now call the drain routines without holding the mutex lock and
recursing into it. This was done for mainly two reasons:

(i) Avoid the long recursion; long recursions are typically bad and this
    is the case here because we block all other code from freeing mbufs
    if they need to. Doing that is kind of counter-productive, since we're
    really hoping that someone will free.

(ii) More importantly, avoid a potential lock order reversal. Right now,
     not all the locks have been added to our networking code; but
     without this change, we're introducing the possibility for deadlock.
     Consider for example ip_drain(). We will likely eventually introduce
     a lock for ipq there, and so ip_freef() will be called with ipq lock
     held. But, ip_freef() calls m_freem() which in turn acquires the
     mmbfree lock. Since we were previously calling ip_drain() with mmbfree
     held, our lock order would be: mmbfree->ipq->mmbfree. Some other code
     may very well lock ipq first and then call ip_freef(). This would
     result in the regular lock order, ipq->mmbfree. Clearly, we have
     deadlock if one thread acquires the ipq lock and sits waiting for
     mmbfree while another thread calling m_reclaim() acquires mmbfree
     and sits waiting for the ipq lock.

Also, make sure to add a comment above m_reclaim()'s definition briefly
explaining this. Also document this above the call to m_reclaim() in
m_mballoc_wait().

Suggested and reviewed by: alfred
2001-01-09 23:58:56 +00:00
..
alpha The alpha architecture is 64 bits, so bus_addr_t && bus_size_t should really 2001-01-09 18:17:48 +00:00
amd64 Fix a warning. The type of globaldata.gd_prvspace has changed. 2001-01-08 15:25:45 +00:00
arm/include Remove seconds types we don't use that came in thru the NetBSD heiratage. 2001-01-08 06:17:11 +00:00
boot Add commented out examples for the new KTR loader tunables. 2001-01-06 06:52:49 +00:00
cam select() DKI is defined in <sys/selinfo.h> now. 2001-01-09 04:31:48 +00:00
coda Delete unused #include <sys/select.h>. 2001-01-09 04:32:24 +00:00
compat Take 10 seconds to actually fix the chgproccnt rather than just make it 2001-01-09 04:55:37 +00:00
compile
conf moved isp_pci.c from pci to dev/isp 2001-01-09 19:15:12 +00:00
contrib/dev Resolve conflicts from the ACPI CA 20001215 vendor import. 2000-12-21 07:04:32 +00:00
crypto Initial import of AES algorithm code (aka Rijndael) from KAME. 2000-10-30 11:03:32 +00:00
ddb Use macro API for <sys/queue.h> 2000-12-30 22:06:19 +00:00
dev Add a flag value to the board identifiers, and use this to enable the 2001-01-09 14:49:41 +00:00
fs Delete unused #include <sys/select.h>. 2001-01-09 04:32:24 +00:00
geom Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
gnu Completed move of Digiboard drivers to dev/dgb 2001-01-08 02:47:37 +00:00
i4b Move the mutex initialization from avma1pp_bchannel_setup into 2001-01-09 15:01:42 +00:00
i386 select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
ia64 Put VCS ids in a consistent place and form. 2001-01-08 06:24:08 +00:00
isa select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
isofs/cd9660 Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
kern In m_mballoc_wait(), drop the mmbfree mutex lock prior to calling 2001-01-09 23:58:56 +00:00
libkern Add __ucmpdi2 prototype to quelch a warning. 2000-12-07 22:28:20 +00:00
miscfs Don't compile a dead variable declaration. 2001-01-09 04:24:43 +00:00
modules Evidently, svr4 is broken at the moment. Disconnect the build to prevent 2001-01-09 04:56:53 +00:00
msdosfs Use macro API to <sys/queue.h> 2000-12-31 10:24:19 +00:00
net select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
netatalk * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
netatm * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
netgraph Missing FREE(). 2001-01-09 00:49:31 +00:00
netinet o Minor style(9)ism to make consistent with -STABLE 2001-01-09 18:26:17 +00:00
netinet6 do not touch ra_addr if it is NULL. from IIJ SEIL team 2001-01-02 15:17:19 +00:00
netipx * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
netkey Revert previous commit after discussion with phk. 2000-10-30 09:13:46 +00:00
netnatm Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
netncp Common option '-N' do not require an argument. 2001-01-07 07:03:59 +00:00
netns * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
nfs NFS O_EXCL file create semantics temporarily uses file attributes to store 2001-01-04 22:45:19 +00:00
nfsclient NFS O_EXCL file create semantics temporarily uses file attributes to store 2001-01-04 22:45:19 +00:00
nfsserver * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
ntfs Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
nwfs v_interlock is a mutex now, not simple lock. 2000-11-04 02:42:11 +00:00
pc98 Correct typo. 2001-01-08 09:17:58 +00:00
pccard Fix a minor bug that prevents NEWBUS users from setting more than 2001-01-09 23:39:32 +00:00
pci moved isp_pci.c from pci to dev/isp 2001-01-09 19:15:12 +00:00
posix4 Add $FreeBSD$ 2000-05-01 20:32:07 +00:00
powerpc Remove seconds types we don't use that came in thru the NetBSD heiratage. 2001-01-08 06:17:11 +00:00
rpc
svr4 This patchset fixes a large number of file descriptor race conditions. 2000-11-18 21:01:04 +00:00
sys select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
tools Simplify this a bit so that it doesn't have to generate silly redundant 2000-12-06 06:59:38 +00:00
ufs o Commit reems of style(9) changes, whitespace improvements, and comment 2001-01-07 23:45:56 +00:00
vm fix comment which was outdated 3 years ago 2000-12-29 13:49:05 +00:00
Makefile I should know better than to touch this without testing a 'make release' 2000-08-24 18:53:09 +00:00