summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1999-05-12 11:11:27 +0000
committerbde <bde@FreeBSD.org>1999-05-12 11:11:27 +0000
commitc82c114e2f3bd201ddf92db76365176fc85312be (patch)
tree75517c423becda820f414a8bec3f7835a1b483b1 /sys/kern/kern_malloc.c
parent429046ddb475a60027e2720e3a3136e7148f1d90 (diff)
downloadFreeBSD-src-c82c114e2f3bd201ddf92db76365176fc85312be.zip
FreeBSD-src-c82c114e2f3bd201ddf92db76365176fc85312be.tar.gz
Fixed corruption of the kmemstatistcs list. The first malloc()
with malloc type at the tail of the list changed the list from linear to circular. This seemed to cause surprisingly few problems, but it now causes weird output from `vmstat -m', probably because a more important malloc type is now at the tail of the list. Fix it by abusing ks_limit instead of ks_next as a flag for being on the list. Don't forget to clear the flag when a malloc type is uninit'ed. Uninit'ing is still fundamentally broken -- it loses history.
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index e7499d5..0b300c2 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.54 1999/01/27 21:49:56 dillon Exp $
+ * $Id: kern_malloc.c,v 1.55 1999/05/06 18:12:42 peter Exp $
*/
#include "opt_vm.h"
@@ -138,9 +138,8 @@ malloc(size, type, flags)
s = splmem();
- if (!type->ks_next) {
+ if (type->ks_limit == 0)
malloc_init(type);
- }
indx = BUCKETINDX(size);
kbp = &bucket[indx];
@@ -283,7 +282,7 @@ free(addr, type)
#endif
register struct malloc_type *ksp = type;
- if (!type->ks_next)
+ if (type->ks_limit == 0)
panic("freeing with unknown type (%s)", type->ks_shortdesc);
KASSERT(kmembase <= (char *)addr && (char *)addr < kmemlimit,
@@ -466,7 +465,7 @@ malloc_init(data)
if (type->ks_magic != M_MAGIC)
panic("malloc type lacks magic");
- if (type->ks_next)
+ if (type->ks_limit != 0)
return;
if (cnt.v_page_count == 0)
@@ -494,6 +493,9 @@ malloc_uninit(data)
if (cnt.v_page_count == 0)
panic("malloc_uninit not allowed before vm init");
+ if (type->ks_limit == 0)
+ panic("malloc_uninit on uninitialized type");
+
if (type == kmemstatistics)
kmemstatistics = type->ks_next;
else {
@@ -504,4 +506,6 @@ malloc_uninit(data)
}
}
}
+ type->ks_next = NULL;
+ type->ks_limit = 0;
}
OpenPOWER on IntegriCloud