diff options
author | dg <dg@FreeBSD.org> | 1995-03-15 07:52:06 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1995-03-15 07:52:06 +0000 |
commit | c20bdce1e09ff7c3db7910a8b0353fadb210e6f1 (patch) | |
tree | af7ab4a204150cd9c9da398ba2da8588c77fe968 | |
parent | 876858a7b243e8839c039e1eb69306e19c0015dd (diff) | |
download | FreeBSD-src-c20bdce1e09ff7c3db7910a8b0353fadb210e6f1.zip FreeBSD-src-c20bdce1e09ff7c3db7910a8b0353fadb210e6f1.tar.gz |
Special cased the handling of mb_map in the M_WAITOK case. kmem_malloc()
now returns NULL and sets a global 'mb_map_full' when the map is full.
m_clalloc() has further been taught to expect this and do the right thing.
This should fix the "mb_map full" panics that several people have reported.
-rw-r--r-- | sys/kern/uipc_mbuf.c | 23 | ||||
-rw-r--r-- | sys/vm/vm_kern.c | 18 |
2 files changed, 26 insertions, 15 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 55932c6..d71ff9f 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94 - * $Id: uipc_mbuf.c,v 1.7 1995/02/05 07:08:27 bde Exp $ + * $Id: uipc_mbuf.c,v 1.8 1995/02/23 19:10:21 davidg Exp $ */ #include <sys/param.h> @@ -50,6 +50,7 @@ extern vm_map_t mb_map; struct mbuf *mbutl; char *mclrefcnt; +int mb_map_full; void mbinit() @@ -86,16 +87,24 @@ m_clalloc(ncl, nowait) register int i; int npg; + /* + * Once we run out of map space, it will be impossible + * to get any more (nothing is ever freed back to the + * map). + */ + if (mb_map_full) + return (0); + npg = ncl * CLSIZE; p = (caddr_t)kmem_malloc(mb_map, ctob(npg), nowait ? M_NOWAIT : M_WAITOK); - if (p == NULL) { - if (logged == 0) { - logged++; - log(LOG_ERR, "mb_map full\n"); - } + /* + * Either the map is now full, or this is nowait and there + * are no pages left. + */ + if (p == NULL) return (0); - } + ncl = ncl * CLBYTES / MCLBYTES; for (i = 0; i < ncl; i++) { ((union mcluster *)p)->mcl_next = mclfree; diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 96c4bce..47cbb91 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_kern.c,v 1.10 1995/02/02 09:08:33 davidg Exp $ + * $Id: vm_kern.c,v 1.11 1995/02/21 01:22:45 davidg Exp $ */ /* @@ -73,6 +73,7 @@ #include <sys/kernel.h> #include <sys/proc.h> #include <sys/malloc.h> +#include <sys/syslog.h> #include <vm/vm.h> #include <vm/vm_page.h> @@ -89,6 +90,7 @@ vm_map_t pager_map; vm_map_t phys_map; vm_map_t exec_map; vm_map_t u_map; +extern int mb_map_full; /* * kmem_alloc_pageable: @@ -289,7 +291,7 @@ kmem_malloc(map, size, waitflag) vm_page_t m; if (map != kmem_map && map != mb_map) - panic("kern_malloc_alloc: map != {kmem,mb}_map"); + panic("kmem_malloc: map != {kmem,mb}_map"); size = round_page(size); addr = vm_map_min(map); @@ -302,13 +304,13 @@ kmem_malloc(map, size, waitflag) vm_map_lock(map); if (vm_map_findspace(map, 0, size, &addr)) { vm_map_unlock(map); -#if 0 - if (canwait) /* XXX should wait */ - panic("kmem_malloc: %s too small", - map == kmem_map ? "kmem_map" : "mb_map"); -#endif + if (map == mb_map) { + mb_map_full = TRUE; + log(LOG_ERR, "mb_map full\n"); + return (0); + } if (waitflag == M_WAITOK) - panic("kmem_malloc: map too small"); + panic("kmem_malloc: kmem_map too small"); return (0); } offset = addr - vm_map_min(kmem_map); |