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.
This commit is contained in:
parent
429046ddb4
commit
c82c114e2f
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user