From a28a8481af3f2a2145d2a6c164a6299934c2bb3f Mon Sep 17 00:00:00 2001 From: wollman Date: Fri, 10 May 1996 19:28:55 +0000 Subject: Allocate mbufs from a separate submap so that NMBCLUSTERS works as expected. --- sys/amd64/amd64/machdep.c | 11 +++++++++-- sys/conf/param.c | 10 ++++++---- sys/i386/i386/machdep.c | 11 +++++++++-- sys/kern/kern_malloc.c | 14 ++++++++------ sys/kern/subr_param.c | 10 ++++++---- sys/kern/uipc_mbuf.c | 6 +++--- sys/sys/mbuf.h | 3 ++- sys/vm/vm_kern.c | 16 ++++++++++++---- sys/vm/vm_kern.h | 4 +++- 9 files changed, 58 insertions(+), 27 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 86bd0bb..7fa891f 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.188 1996/05/02 22:24:57 phk Exp $ + * $Id: machdep.c,v 1.189 1996/05/03 21:00:53 phk Exp $ */ #include "npx.h" @@ -388,8 +388,15 @@ again: mclrefcnt = (char *)malloc(nmbclusters+PAGE_SIZE/MCLBYTES, M_MBUF, M_NOWAIT); bzero(mclrefcnt, nmbclusters+PAGE_SIZE/MCLBYTES); - mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, + mcl_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, nmbclusters * MCLBYTES, FALSE); + { + vm_size_t mb_map_size; + mb_map_size = nmbufs * MSIZE; + mb_map = kmem_suballoc(kmem_map, &minaddr, &maxaddr, + round_page(mb_map_size), FALSE); + } + /* * Initialize callouts */ diff --git a/sys/conf/param.c b/sys/conf/param.c index da221c8..f86e749 100644 --- a/sys/conf/param.c +++ b/sys/conf/param.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)param.c 8.3 (Berkeley) 8/20/94 - * $Id: param.c,v 1.17 1996/05/02 10:42:51 phk Exp $ + * $Id: param.c,v 1.18 1996/05/02 14:19:18 phk Exp $ */ #include "opt_sysvipc.h" @@ -91,10 +91,12 @@ int ncallout = 16 + NPROC; /* maximum # of timer events */ /* maximum # of mbuf clusters */ #ifndef NMBCLUSTERS -int nmbclusters = 512 + MAXUSERS * 16; -#else -int nmbclusters = NMBCLUSTERS; +#define NMBCLUSTERS (512 + MAXUSERS * 16) #endif +int nmbclusters = NMBCLUSTERS; + +/* allocate same amount of virtual address space for mbufs XXX */ +int nmbufs = NMBCLUSTERS * (MCLBYTES / MSIZE); int fscale = FSCALE; /* kernel uses `FSCALE', user uses `fscale' */ diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 86bd0bb..7fa891f 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.188 1996/05/02 22:24:57 phk Exp $ + * $Id: machdep.c,v 1.189 1996/05/03 21:00:53 phk Exp $ */ #include "npx.h" @@ -388,8 +388,15 @@ again: mclrefcnt = (char *)malloc(nmbclusters+PAGE_SIZE/MCLBYTES, M_MBUF, M_NOWAIT); bzero(mclrefcnt, nmbclusters+PAGE_SIZE/MCLBYTES); - mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, + mcl_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, nmbclusters * MCLBYTES, FALSE); + { + vm_size_t mb_map_size; + mb_map_size = nmbufs * MSIZE; + mb_map = kmem_suballoc(kmem_map, &minaddr, &maxaddr, + round_page(mb_map_size), FALSE); + } + /* * Initialize callouts */ diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index bfdc4bb..b348a3c 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94 - * $Id: kern_malloc.c,v 1.20 1996/05/02 10:43:17 phk Exp $ + * $Id: kern_malloc.c,v 1.21 1996/05/02 14:20:20 phk Exp $ */ #include @@ -372,15 +372,16 @@ kmeminit(dummy) int npg; #if ((MAXALLOCSAVE & (MAXALLOCSAVE - 1)) != 0) - ERROR!_kmeminit:_MAXALLOCSAVE_not_power_of_2 +#error "kmeminit: MAXALLOCSAVE not power of 2" #endif #if (MAXALLOCSAVE > MINALLOCSIZE * 32768) - ERROR!_kmeminit:_MAXALLOCSAVE_too_big +#error "kmeminit: MAXALLOCSAVE too big" #endif #if (MAXALLOCSAVE < PAGE_SIZE) - ERROR!_kmeminit:_MAXALLOCSAVE_too_small +#error "kmeminit: MAXALLOCSAVE too small" #endif - npg = (nmbclusters * MCLBYTES + VM_KMEM_SIZE) / PAGE_SIZE; + npg = (nmbufs * MSIZE + nmbclusters * MCLBYTES + VM_KMEM_SIZE) + / PAGE_SIZE; kmemusage = (struct kmemusage *) kmem_alloc(kernel_map, (vm_size_t)(npg * sizeof(struct kmemusage))); @@ -401,7 +402,8 @@ kmeminit(dummy) */ for (indx = 0; indx < M_LAST; indx++) { kmemstats[indx].ks_limit = min(cnt.v_page_count * PAGE_SIZE, - (npg * PAGE_SIZE - nmbclusters * MCLBYTES)) * 6 / 10; + (npg * PAGE_SIZE - nmbclusters * MCLBYTES + - nmbufs * MSIZE)) * 6 / 10; } #endif } diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index da221c8..f86e749 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)param.c 8.3 (Berkeley) 8/20/94 - * $Id: param.c,v 1.17 1996/05/02 10:42:51 phk Exp $ + * $Id: param.c,v 1.18 1996/05/02 14:19:18 phk Exp $ */ #include "opt_sysvipc.h" @@ -91,10 +91,12 @@ int ncallout = 16 + NPROC; /* maximum # of timer events */ /* maximum # of mbuf clusters */ #ifndef NMBCLUSTERS -int nmbclusters = 512 + MAXUSERS * 16; -#else -int nmbclusters = NMBCLUSTERS; +#define NMBCLUSTERS (512 + MAXUSERS * 16) #endif +int nmbclusters = NMBCLUSTERS; + +/* allocate same amount of virtual address space for mbufs XXX */ +int nmbufs = NMBCLUSTERS * (MCLBYTES / MSIZE); int fscale = FSCALE; /* kernel uses `FSCALE', user uses `fscale' */ diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 9c2d315..f742628 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.19 1996/05/06 17:18:12 phk Exp $ + * $Id: uipc_mbuf.c,v 1.20 1996/05/08 19:38:14 wollman Exp $ */ #include @@ -152,11 +152,11 @@ m_clalloc(ncl, nowait) * to get any more (nothing is ever freed back to the * map). */ - if (mb_map_full) + if (mcl_map_full) return (0); npg = ncl; - p = (caddr_t)kmem_malloc(mb_map, ctob(npg), + p = (caddr_t)kmem_malloc(mcl_map, ctob(npg), nowait ? M_NOWAIT : M_WAITOK); /* * Either the map is now full, or this is nowait and there diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 8d090d5..a00dcf4 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 - * $Id: mbuf.h,v 1.14 1996/03/11 02:14:16 hsu Exp $ + * $Id: mbuf.h,v 1.15 1996/05/08 19:38:27 wollman Exp $ */ #ifndef _SYS_MBUF_H_ @@ -394,6 +394,7 @@ extern struct mbuf *mbutl; /* virtual address of mclusters */ extern char *mclrefcnt; /* cluster reference counts */ extern struct mbstat mbstat; extern int nmbclusters; +extern int nmbufs; extern struct mbuf *mmbfree; extern union mcluster *mclfree; extern int max_linkhdr; /* largest link-level header */ diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index dcefdc0..a820f9d 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.22 1996/01/31 12:05:52 davidg Exp $ + * $Id: vm_kern.c,v 1.23 1996/04/24 04:16:44 dyson Exp $ */ /* @@ -94,6 +94,8 @@ vm_map_t kernel_map; vm_map_t kmem_map; vm_map_t mb_map; int mb_map_full; +vm_map_t mcl_map; +int mcl_map_full; vm_map_t io_map; vm_map_t clean_map; vm_map_t phys_map; @@ -291,8 +293,8 @@ kmem_malloc(map, size, waitflag) vm_offset_t addr; vm_page_t m; - if (map != kmem_map && map != mb_map) - panic("kmem_malloc: map != {kmem,mb}_map"); + if (map != kmem_map && map != mb_map && map != mcl_map) + panic("kmem_malloc: map != {kmem,mb,mcl}_map"); size = round_page(size); addr = vm_map_min(map); @@ -307,7 +309,13 @@ kmem_malloc(map, size, waitflag) vm_map_unlock(map); if (map == mb_map) { mb_map_full = TRUE; - log(LOG_ERR, "Out of mbuf clusters - increase maxusers!\n"); + log(LOG_ERR, "Out of mbufs - increase maxusers!\n"); + return (0); + } + if (map == mcl_map) { + mcl_map_full = TRUE; + log(LOG_ERR, + "Out of mbuf clusters - increase maxusers!\n"); return (0); } if (waitflag == M_WAITOK) diff --git a/sys/vm/vm_kern.h b/sys/vm/vm_kern.h index 57f4f1a..8fcbb04 100644 --- a/sys/vm/vm_kern.h +++ b/sys/vm/vm_kern.h @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_kern.h,v 1.5 1995/01/09 16:05:44 davidg Exp $ + * $Id: vm_kern.h,v 1.6 1995/07/29 11:44:22 bde Exp $ */ #ifndef _VM_VM_KERN_H_ @@ -73,6 +73,8 @@ extern vm_map_t kernel_map; extern vm_map_t kmem_map; extern vm_map_t mb_map; extern int mb_map_full; +extern vm_map_t mcl_map; +extern int mcl_map_full; extern vm_map_t io_map; extern vm_map_t clean_map; extern vm_map_t phys_map; -- cgit v1.1