freebsd-nq/sys/kern
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
..
bus_if.m Alter the return value and arguments of the GET_RESOURCE_LIST bus method. 2000-11-28 06:49:15 +00:00
device_if.m * Factor out the object system from new-bus so that it can be used by 2000-04-08 14:17:18 +00:00
genassym.sh Use "nm | awk ..." instead of genassym(1) to generate symbol value headers. 2000-06-02 09:27:48 +00:00
imgact_aout.c Change the proc information returned from the kernel so that it 2000-12-12 07:25:57 +00:00
imgact_elf.c - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), instead 2000-12-13 00:17:05 +00:00
imgact_gzip.c useracc() the prequel: 1999-10-29 18:09:36 +00:00
imgact_shell.c Fix #! script exec under linux emulation. If a script is exec'd from a 2000-04-26 20:58:40 +00:00
inflate.c Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL" 1999-12-29 05:07:58 +00:00
init_main.c - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), instead 2000-12-13 00:17:05 +00:00
init_sysent.c Regen. 2000-12-02 05:45:32 +00:00
kern_acct.c Use callout_reset instead of timeout(9). Most callouts are statically 2000-11-27 22:52:31 +00:00
kern_acl.c Staticize some malloc M_ instances. 2000-12-08 20:09:00 +00:00
kern_cap.c Remove unneeded #include <sys/proc.h> lines. 2000-10-29 13:57:19 +00:00
kern_clock.c o Export cp_time ("CPU time statistics") using SYSCTL_OPAQUE. 2000-11-20 00:44:58 +00:00
kern_conf.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
kern_descrip.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
kern_environment.c Previous commit changing SYSCTL_HANDLER_ARGS violated KNF. 2000-07-04 11:25:35 +00:00
kern_event.c select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
kern_exec.c Protect proc.p_pptr and proc.p_children/p_sibling with the 2000-12-23 19:43:10 +00:00
kern_exit.c Protect proc.p_pptr and proc.p_children/p_sibling with the 2000-12-23 19:43:10 +00:00
kern_fork.c Protect proc.p_pptr and proc.p_children/p_sibling with the 2000-12-23 19:43:10 +00:00
kern_idle.c Catch up to moving headers: 2000-10-20 07:58:15 +00:00
kern_intr.c Ignore a net interrupt if the corresponding handler is not 2000-12-31 01:31:55 +00:00
kern_jail.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
kern_kthread.c Protect proc.p_pptr and proc.p_children/p_sibling with the 2000-12-23 19:43:10 +00:00
kern_ktr.c - Move all of the KTR sysctl's under a new debug.ktr mib. 2001-01-06 06:51:43 +00:00
kern_ktrace.c Don't use SCARG. 2001-01-08 07:22:06 +00:00
kern_linker.c Pull out the module path from the loader. ie: if you boot from 2000-12-28 08:14:58 +00:00
kern_lock.c Use msleep instead of mtx_exit; tsleep; mtx_enter, which is not safe. 2000-12-01 02:18:38 +00:00
kern_lockf.c Commit the remaining part of PR14914: 1999-11-16 16:28:58 +00:00
kern_malloc.c Introduce the M_ZERO flag to malloc(9) 2000-10-20 17:54:55 +00:00
kern_mib.c Previous commit changing SYSCTL_HANDLER_ARGS violated KNF. 2000-07-04 11:25:35 +00:00
kern_module.c Staticize some malloc M_ instances. 2000-12-08 20:09:00 +00:00
kern_mutex.c - Add a new flag MTX_QUIET that can be passed to the various mtx_* 2000-12-13 21:53:42 +00:00
kern_ntptime.c Updates to the ntp pll from John Hay. 2000-09-10 09:13:34 +00:00
kern_physio.c Separate the struct bio related stuff out of <sys/buf.h> into 2000-05-05 09:59:14 +00:00
kern_proc.c Protect proc.p_pptr and proc.p_children/p_sibling with the 2000-12-23 19:43:10 +00:00
kern_prot.c Protect proc.p_pptr and proc.p_children/p_sibling with the 2000-12-23 19:43:10 +00:00
kern_random.c This patchset fixes a large number of file descriptor race conditions. 2000-11-18 21:01:04 +00:00
kern_resource.c - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), instead 2000-12-13 00:17:05 +00:00
kern_shutdown.c Stick the kthread API in a kthread_* namespace, and the specialized kproc 2000-12-15 20:08:20 +00:00
kern_sig.c Protect p_nice and P_TRACED in psignal() above the switch statement with 2001-01-06 00:08:39 +00:00
kern_subr.c - Split the run queue and sleep queue linkage, so that a process 2000-11-17 18:09:18 +00:00
kern_switch.c Catch up to moving headers: 2000-10-20 07:58:15 +00:00
kern_synch.c - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), instead 2000-12-13 00:17:05 +00:00
kern_syscalls.c sysvipc loadable. 2000-12-01 08:57:47 +00:00
kern_sysctl.c - For dynamic sysctl's added at runtime, don't assume that the name passed 2001-01-05 07:00:45 +00:00
kern_tc.c Remove a bogus #ifdef KTR stanza. 2001-01-01 23:09:53 +00:00
kern_time.c Use callout_reset instead of timeout(9). Most callouts are statically 2000-11-27 22:52:31 +00:00
kern_timeout.c Revert the last commit to the callout interface, and add a flag to 2000-11-25 06:22:16 +00:00
kern_xxx.c $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
ksched.c Remove unneeded #include <sys/kernel.h> 2000-04-29 15:36:14 +00:00
link_aout.c Change the conditionaal so that we only build this on i386 instead of 2000-09-29 13:32:24 +00:00
link_elf_obj.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
link_elf.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
linker_if.m First round implementation of a fine grain enhanced module to module 2000-04-29 13:19:31 +00:00
Make.tags.inc there is no more miscfs/devfs 2000-12-31 23:12:20 +00:00
makedevops.pl Fix a bug in both scripts: HEADER sections were not emitted to the header 2001-01-04 13:41:24 +00:00
Makefile Retire kernfs (kernel part). 2000-12-28 12:17:35 +00:00
makeobjops.pl Fix a bug in both scripts: HEADER sections were not emitted to the header 2001-01-04 13:41:24 +00:00
makesyscalls.sh Add reserved lkmressys keyword. I swear, this script will die the 2000-12-01 08:47:54 +00:00
md5c.c Add ia64 support. 2000-09-29 13:36:47 +00:00
p1003_1b.c Add $FreeBSD$ 2000-05-01 20:32:07 +00:00
posix4_mib.c Add $FreeBSD$. 2000-04-22 15:13:06 +00:00
subr_acl_posix1e.c Staticize some malloc M_ instances. 2000-12-08 20:09:00 +00:00
subr_autoconf.c Back out the previous change to the queue(3) interface. 2000-05-26 02:09:24 +00:00
subr_blist.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
subr_bus.c Unset the devclass if the attach fails and the devclass was not set to 2001-01-08 22:16:26 +00:00
subr_clist.c $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
subr_devstat.c Support for unsigned integer and long sysctl variables. Update the 2000-07-05 07:46:41 +00:00
subr_disk.c Don't clone impossible unit numbers for disks. 2000-12-15 17:55:24 +00:00
subr_disklabel.c Make diskerr() always log with printf. 2000-11-26 19:29:15 +00:00
subr_diskmbr.c Make diskerr() always log with printf. 2000-11-26 19:29:15 +00:00
subr_diskslice.c Add a new ioctl for doing virgin disklabels. 2000-10-31 07:05:40 +00:00
subr_eventhandler.c - Convert the per-eventhandler list mutex to a lockmgr lock so that it can 2000-12-12 04:01:35 +00:00
subr_kobj.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
subr_log.c Replace logwakeup() with "int msgbuftrigger". There is little 2000-12-20 21:50:37 +00:00
subr_module.c Trim unused options (or #ifdef for undoc options). 1999-10-11 15:19:12 +00:00
subr_param.c Remove unneeded <stddef.h> #includes. 2000-10-29 16:57:42 +00:00
subr_prf.c Make sure we have a non-null proc pointer before referring to fields 2000-12-23 07:33:32 +00:00
subr_prof.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
subr_rman.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
subr_sbuf.c String buffer API 2000-12-13 19:51:07 +00:00
subr_scanf.c Change the prototype of the strto* routines to make the second 1999-11-24 01:03:08 +00:00
subr_smp.c Fix a warning. The type of globaldata.gd_prvspace has changed. 2001-01-08 15:25:45 +00:00
subr_taskqueue.c Staticize some malloc M_ instances. 2000-12-08 20:09:00 +00:00
subr_trap.c If we fail to emulate a vm86 trap in kernel mode, then we use 2000-12-13 18:57:15 +00:00
subr_turnstile.c - Add a new flag MTX_QUIET that can be passed to the various mtx_* 2000-12-13 21:53:42 +00:00
subr_witness.c - Add a new flag MTX_QUIET that can be passed to the various mtx_* 2000-12-13 21:53:42 +00:00
subr_xxx.c Remove five now unused fields from struct cdevsw. They should never 1999-09-25 18:24:47 +00:00
sys_generic.c select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
sys_pipe.c select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
sys_process.c Backout rev 1.57 & 1.58. While the previous revisions fixed 2000-12-31 01:30:27 +00:00
sys_socket.c Instead of just blindly setting -rw-rw-rw-: 2000-07-02 23:56:45 +00:00
syscalls.c Regen. 2000-12-02 05:45:32 +00:00
syscalls.master Remove thr_sleep and thr_wakeup. Remove fields p_nthread and p_wakeup 2000-12-02 05:41:30 +00:00
sysv_ipc.c sysvipc loadable. 2000-12-01 08:57:47 +00:00
sysv_msg.c Add forgotten SYSCALL_MODULE_HELPER() for msgsys() syscall. 2000-12-05 23:05:45 +00:00
sysv_sem.c sysvipc loadable. 2000-12-01 08:57:47 +00:00
sysv_shm.c sysvipc loadable. 2000-12-01 08:57:47 +00:00
tty_compat.c $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
tty_conf.c Don't refer to TABLDISC in the comments here. 2000-01-30 10:14:13 +00:00
tty_cons.c Replace logwakeup() with "int msgbuftrigger". There is little 2000-12-20 21:50:37 +00:00
tty_pty.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
tty_snoop.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
tty_subr.c $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
tty_tty.c Add snapshots to the fast filesystem. Most of the changes support 2000-07-11 22:07:57 +00:00
tty.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
uipc_accf.c Remove unneeded #include <sys/proc.h> lines. 2000-10-29 13:57:19 +00:00
uipc_domain.c Use callout_reset instead of timeout(9). Most callouts are statically 2000-11-27 22:52:31 +00:00
uipc_mbuf2.c * Have m_pulldown() use the new M_WRITABLE() macro in order to determine 2000-11-11 23:04:15 +00:00
uipc_mbuf.c In m_mballoc_wait(), drop the mmbfree mutex lock prior to calling 2001-01-09 23:58:56 +00:00
uipc_proto.c Trim unused options (or #ifdef for undoc options). 1999-10-11 15:19:12 +00:00
uipc_sockbuf.c Make sbcompress use the new M_WRITABLE macro. Previously sbcompress 2000-11-19 22:22:47 +00:00
uipc_socket2.c Make sbcompress use the new M_WRITABLE macro. Previously sbcompress 2000-11-19 22:22:47 +00:00
uipc_socket.c * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
uipc_syscalls.c Fix the <sys/queue.h> abuse. 2001-01-02 11:51:55 +00:00
uipc_usrreq.c * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
vfs_acl.c Staticize some malloc M_ instances. 2000-12-08 20:09:00 +00:00
vfs_aio.c Remove thr_sleep and thr_wakeup. Remove fields p_nthread and p_wakeup 2000-12-02 05:41:30 +00:00
vfs_bio.c This implements a better launder limiting solution. There was a solution 2000-12-26 19:41:38 +00:00
vfs_cache.c Staticize some malloc M_ instances. 2000-12-08 20:09:00 +00:00
vfs_cluster.c This implements a better launder limiting solution. There was a solution 2000-12-26 19:41:38 +00:00
vfs_conf.c Add `_PATH_DEVZERO'. 2000-12-09 09:35:55 +00:00
vfs_default.c Give vop_mmap an untimely death. The opportunity to give it a timely 2000-11-01 17:57:24 +00:00
vfs_export.c Stick the kthread API in a kthread_* namespace, and the specialized kproc 2000-12-15 20:08:20 +00:00
vfs_extattr.c - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), instead 2000-12-13 00:17:05 +00:00
vfs_init.c Convert more malloc+bzero to malloc+M_ZERO. 2000-12-08 21:51:06 +00:00
vfs_lookup.c Untangle vfsinit() a bit. Use seperate sysinit functions rather than 2000-12-06 07:09:08 +00:00
vfs_mount.c Add `_PATH_DEVZERO'. 2000-12-09 09:35:55 +00:00
vfs_subr.c Stick the kthread API in a kthread_* namespace, and the specialized kproc 2000-12-15 20:08:20 +00:00
vfs_syscalls.c - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), instead 2000-12-13 00:17:05 +00:00
vfs_vnops.c Implement a low-memory deadlock solution. 2000-11-18 23:06:26 +00:00
vnode_if.pl Simplify this a bit so that it doesn't have to generate silly redundant 2000-12-06 06:59:38 +00:00
vnode_if.src Give vop_mmap an untimely death. The opportunity to give it a timely 2000-11-01 17:57:24 +00:00