sys/malloc.h:
Order the SYSINIT() for MALLOC_DEFINE() correctly so that malloc() doesn't have to waste time initializing itself. The (SI_SUB_KMEM, SI_ORDER_ANY) order was shared with syscons' SYSINIT() for scmeminit(), and scmeminit() calls malloc(), so malloc() initialization was not always complete on the first call to malloc(). kern/kern_malloc.c: - Removed self-initialization in malloc(). - Removed half-baked sanity check in free(). Trust MALLOC_DEFINE().
This commit is contained in:
parent
7c0bc50d70
commit
8e8cac5555
@ -147,19 +147,9 @@ malloc(size, type, flags)
|
||||
KASSERT(intr_nesting_level == 0,
|
||||
("malloc(M_WAITOK) in interrupt context"));
|
||||
#endif
|
||||
/*
|
||||
* Must be at splmem() prior to initializing segment to handle
|
||||
* potential initialization race.
|
||||
*/
|
||||
|
||||
s = splmem();
|
||||
|
||||
if (type->ks_limit == 0)
|
||||
malloc_init(type);
|
||||
|
||||
indx = BUCKETINDX(size);
|
||||
kbp = &bucket[indx];
|
||||
|
||||
s = splmem();
|
||||
while (ksp->ks_memuse >= ksp->ks_limit) {
|
||||
if (flags & M_ASLEEP) {
|
||||
if (ksp->ks_limblocks < 65535)
|
||||
@ -298,9 +288,6 @@ free(addr, type)
|
||||
#endif
|
||||
register struct malloc_type *ksp = type;
|
||||
|
||||
if (type->ks_limit == 0)
|
||||
panic("freeing with unknown type (%s)", type->ks_shortdesc);
|
||||
|
||||
KASSERT(kmembase <= (char *)addr && (char *)addr < kmemlimit,
|
||||
("free: address %p out of range", (void *)addr));
|
||||
kup = btokup(addr);
|
||||
|
@ -68,7 +68,7 @@ struct malloc_type {
|
||||
struct malloc_type type[1] = { \
|
||||
{ NULL, 0, 0, 0, 0, 0, 0, M_MAGIC, shortdesc, 0, 0 } \
|
||||
}; \
|
||||
SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_ANY, malloc_init, type); \
|
||||
SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, type); \
|
||||
SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, malloc_uninit, type)
|
||||
|
||||
#define MALLOC_DECLARE(type) \
|
||||
|
Loading…
Reference in New Issue
Block a user