summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1996-01-29 09:58:34 +0000
committerdg <dg@FreeBSD.org>1996-01-29 09:58:34 +0000
commitbc2512f99f2695dc10abcf0a7ba23988230e5792 (patch)
treef407bc8a3fb5ad638220bfd5a0abe8f5b6d8d1fc /sys/kern/kern_malloc.c
parent584809c4229024f282a2fd30ee646d2fc0cc078d (diff)
downloadFreeBSD-src-bc2512f99f2695dc10abcf0a7ba23988230e5792.zip
FreeBSD-src-bc2512f99f2695dc10abcf0a7ba23988230e5792.tar.gz
Fixed two bugs in the calculation of the malloc area (kmem_map) size:
1) The calculation didn't account for NMBCLUSTERS, so if a large number of clusters was specified, it would leave little or no space for kernel malloc. 2) It was bogusly restricted to v_page_count. This doesn't take into account the sparseness of the malloc area and would have caused problems on machines with small amounts of memory. It should probably instead be changed to set the malloc limit to be constrained by the amount of memory, but I didn't do this.
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 4588a0b..185d497 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.16 1995/12/07 12:46:44 davidg Exp $
+ * $Id: kern_malloc.c,v 1.17 1995/12/14 08:31:28 phk Exp $
*/
#include <sys/param.h>
@@ -39,6 +39,7 @@
#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/mbuf.h>
#include <sys/vmmeter.h>
#include <vm/vm.h>
@@ -379,14 +380,13 @@ kmeminit(dummy)
#if (MAXALLOCSAVE < CLBYTES)
ERROR!_kmeminit:_MAXALLOCSAVE_too_small
#endif
- npg = VM_KMEM_SIZE/ NBPG;
- if( npg > cnt.v_page_count)
- npg = cnt.v_page_count;
+ npg = (nmbclusters * MCLBYTES + VM_KMEM_SIZE) / PAGE_SIZE;
kmemusage = (struct kmemusage *) kmem_alloc(kernel_map,
(vm_size_t)(npg * sizeof(struct kmemusage)));
kmem_map = kmem_suballoc(kernel_map, (vm_offset_t *)&kmembase,
- (vm_offset_t *)&kmemlimit, (vm_size_t)(npg * NBPG), FALSE);
+ (vm_offset_t *)&kmemlimit, (vm_size_t)(npg * PAGE_SIZE),
+ FALSE);
#ifdef KMEMSTATS
for (indx = 0; indx < MINBUCKET + 16; indx++) {
if (1 << indx >= CLBYTES)
@@ -395,7 +395,9 @@ kmeminit(dummy)
bucket[indx].kb_elmpercl = CLBYTES / (1 << indx);
bucket[indx].kb_highwat = 5 * bucket[indx].kb_elmpercl;
}
- for (indx = 0; indx < M_LAST; indx++)
- kmemstats[indx].ks_limit = npg * NBPG * 6 / 10;
+ for (indx = 0; indx < M_LAST; indx++) {
+ kmemstats[indx].ks_limit = (npg * PAGE_SIZE -
+ nmbclusters * MCLBYTES) * 6 / 10;
+ }
#endif
}
OpenPOWER on IntegriCloud