1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Allocate mbufs from a separate submap so that NMBCLUSTERS works as

expected.
This commit is contained in:
Garrett Wollman 1996-05-10 19:28:55 +00:00
parent ebf0ec62f5
commit cb7545a995
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=15722
9 changed files with 58 additions and 27 deletions

View File

@ -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 @@ cpu_startup(dummy)
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
*/

View File

@ -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' */

View File

@ -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 @@ cpu_startup(dummy)
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
*/

View File

@ -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 <sys/param.h>
@ -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
}

View File

@ -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' */

View File

@ -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 <sys/param.h>
@ -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

View File

@ -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 */

View File

@ -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)

View File

@ -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;