From 8f95dc8729437a6546a3777106f64d1c671d8ac3 Mon Sep 17 00:00:00 2001 From: "Alfred M. Szmidt" Date: Wed, 1 Dec 2004 06:10:11 +0000 Subject: 2004-09-07 Neal H. Walfield * linux/dev/glue/block.c (__brelse): Unconditionally kfree BH. (getblk): Unconditionally kalloc BH. * kern/kalloc.c [!NDEBUG] (kalloc_init_called): New static variable. (kalloc_init): Assert that kalloc_init_called is zero. [! NDEBUG] Set kalloc_init_called to 1 on success. (kalloc): Assert that kalloc_init_called is non-zero. (kget): Likewise. (kfree): Likewise. --- kern/kalloc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'kern/kalloc.c') diff --git a/kern/kalloc.c b/kern/kalloc.c index 5390139..24dfe68 100644 --- a/kern/kalloc.c +++ b/kern/kalloc.c @@ -106,12 +106,18 @@ unsigned long k_zone_max[16] = { * This initializes all of the zones. */ +#ifndef NDEBUG +static int kalloc_init_called; +#endif + void kalloc_init() { vm_offset_t min, max; vm_size_t size; register int i; + assert (! kalloc_init_called); + kalloc_map = kmem_suballoc(kernel_map, &min, &max, kalloc_map_size, FALSE); @@ -142,6 +148,10 @@ void kalloc_init() size >= PAGE_SIZE ? ZONE_COLLECTABLE : 0, k_zone_name[i]); } + +#ifndef NDEBUG + kalloc_init_called = 1; +#endif } vm_offset_t kalloc(size) @@ -153,6 +163,8 @@ vm_offset_t kalloc(size) /* compute the size of the block that we will actually allocate */ + assert (kalloc_init_called); + allocsize = size; if (size < kalloc_max) { allocsize = MINSIZE; @@ -185,6 +197,8 @@ vm_offset_t kget(size) register vm_size_t allocsize; vm_offset_t addr; + assert (kalloc_init_called); + /* compute the size of the block that we will actually allocate */ allocsize = size; @@ -219,6 +233,8 @@ kfree(data, size) register int zindex; register vm_size_t freesize; + assert (kalloc_init_called); + freesize = size; if (size < kalloc_max) { freesize = MINSIZE; -- cgit v1.2.3