From b64b660cd30bcc23284bf62f98870f1b3ed647da Mon Sep 17 00:00:00 2001 From: David Greenman Date: Thu, 25 May 1995 07:41:28 +0000 Subject: [PATCH] Made "NMBCLUSTERS" calculation dynamic and fixed bogus use of "NMBCLUSTERS" in machdep.c (it should use the global nmbclusters). Moved the calculation of nmbclusters into conf/param.c (same place where nmbclusters has always been assigned), and made the calculation include an extra amount based on "maxusers". NMBCLUSTERS can still be overrided in the kernel config file as always, but this change will make that generally unnecessary. This fixes the "bug" reports from people who have misconfigured kernels seeing the network hang when the mbuf cluster pool runs out. Reviewed by: John Dyson --- sys/amd64/amd64/genassym.c | 3 +-- sys/amd64/amd64/machdep.c | 8 ++++---- sys/amd64/include/vmparam.h | 3 +-- sys/i386/i386/genassym.c | 3 +-- sys/i386/i386/machdep.c | 8 ++++---- sys/i386/include/param.h | 10 +--------- sys/i386/include/vmparam.h | 3 +-- 7 files changed, 13 insertions(+), 25 deletions(-) diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index 559341c62b4..dbfb2a06335 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $Id: genassym.c,v 1.24 1995/02/14 06:00:17 phk Exp $ + * $Id: genassym.c,v 1.25 1995/02/14 18:01:24 phk Exp $ */ #include @@ -121,7 +121,6 @@ main() printf("#define\tVM_MAXUSER_ADDRESS 0x%lx\n", VM_MAXUSER_ADDRESS); printf("#define\tKERNBASE 0x%x\n", KERNBASE); printf("#define\tMSGBUFPTECNT %d\n", btoc(sizeof (struct msgbuf))); - printf("#define\tNMBCLUSTERS %d\n", NMBCLUSTERS); printf("#define\tMCLBYTES %d\n", MCLBYTES); printf("#define\tPCB_LINK %p\n", &pcb->pcb_tss.tss_link); printf("#define\tPCB_ESP0 %p\n", &pcb->pcb_tss.tss_esp0); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index dc5103e9eb5..2f299b19c9d 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.125 1995/05/11 19:26:08 rgrimes Exp $ + * $Id: machdep.c,v 1.126 1995/05/12 19:17:14 wollman Exp $ */ #include "npx.h" @@ -342,11 +342,11 @@ again: * Finally, allocate mbuf pool. Since mclrefcnt is an off-size * we use the more space efficient malloc in place of kmem_alloc. */ - mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES, + mclrefcnt = (char *)malloc(nmbclusters+CLBYTES/MCLBYTES, M_MBUF, M_NOWAIT); - bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES); + bzero(mclrefcnt, nmbclusters+CLBYTES/MCLBYTES); mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, - VM_MBUF_SIZE, FALSE); + nmbclusters * MCLBYTES, FALSE); /* * Initialize callouts */ diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index b38e914dd7c..8ff3b451fcc 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 - * $Id: vmparam.h,v 1.16 1994/09/23 07:00:12 davidg Exp $ + * $Id: vmparam.h,v 1.17 1995/01/09 16:04:44 davidg Exp $ */ @@ -127,7 +127,6 @@ #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)KERNBASE + NKPDE*NBPG*NPTEPG) /* virtual sizes (bytes) for various kernel submaps */ -#define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES) #define VM_KMEM_SIZE (32 * 1024 * 1024) #define VM_PHYS_SIZE (USRIOSIZE*CLBYTES) diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 559341c62b4..dbfb2a06335 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $Id: genassym.c,v 1.24 1995/02/14 06:00:17 phk Exp $ + * $Id: genassym.c,v 1.25 1995/02/14 18:01:24 phk Exp $ */ #include @@ -121,7 +121,6 @@ main() printf("#define\tVM_MAXUSER_ADDRESS 0x%lx\n", VM_MAXUSER_ADDRESS); printf("#define\tKERNBASE 0x%x\n", KERNBASE); printf("#define\tMSGBUFPTECNT %d\n", btoc(sizeof (struct msgbuf))); - printf("#define\tNMBCLUSTERS %d\n", NMBCLUSTERS); printf("#define\tMCLBYTES %d\n", MCLBYTES); printf("#define\tPCB_LINK %p\n", &pcb->pcb_tss.tss_link); printf("#define\tPCB_ESP0 %p\n", &pcb->pcb_tss.tss_esp0); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index dc5103e9eb5..2f299b19c9d 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.125 1995/05/11 19:26:08 rgrimes Exp $ + * $Id: machdep.c,v 1.126 1995/05/12 19:17:14 wollman Exp $ */ #include "npx.h" @@ -342,11 +342,11 @@ again: * Finally, allocate mbuf pool. Since mclrefcnt is an off-size * we use the more space efficient malloc in place of kmem_alloc. */ - mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES, + mclrefcnt = (char *)malloc(nmbclusters+CLBYTES/MCLBYTES, M_MBUF, M_NOWAIT); - bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES); + bzero(mclrefcnt, nmbclusters+CLBYTES/MCLBYTES); mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, - VM_MBUF_SIZE, FALSE); + nmbclusters * MCLBYTES, FALSE); /* * Initialize callouts */ diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h index ed5f67fd5ad..716c19b64b7 100644 --- a/sys/i386/include/param.h +++ b/sys/i386/include/param.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $Id: param.h,v 1.17 1995/01/23 19:21:49 davidg Exp $ + * $Id: param.h,v 1.18 1995/02/19 10:36:17 gpalmer Exp $ */ #ifndef _MACHINE_PARAM_H_ @@ -108,14 +108,6 @@ #define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ #define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ -#ifndef NMBCLUSTERS -#ifdef GATEWAY -#define NMBCLUSTERS 512 /* map size, max cluster allocation */ -#else -#define NMBCLUSTERS 256 /* map size, max cluster allocation */ -#endif /* GATEWAY */ -#endif /* NMBCLUSTERS */ - /* * Some macros for units conversion */ diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h index b38e914dd7c..8ff3b451fcc 100644 --- a/sys/i386/include/vmparam.h +++ b/sys/i386/include/vmparam.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 - * $Id: vmparam.h,v 1.16 1994/09/23 07:00:12 davidg Exp $ + * $Id: vmparam.h,v 1.17 1995/01/09 16:04:44 davidg Exp $ */ @@ -127,7 +127,6 @@ #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)KERNBASE + NKPDE*NBPG*NPTEPG) /* virtual sizes (bytes) for various kernel submaps */ -#define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES) #define VM_KMEM_SIZE (32 * 1024 * 1024) #define VM_PHYS_SIZE (USRIOSIZE*CLBYTES)