diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | kern/kalloc.c | 16 | ||||
-rw-r--r-- | linux/dev/glue/block.c | 12 |
3 files changed, 32 insertions, 9 deletions
@@ -1,3 +1,16 @@ +2004-09-07 Neal H. Walfield <neal@cs.uml.edu> + + * 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. + 2004-11-22 Guillem Jover <guillem@hadrons.org> * i386/i386/locore.S (discover_x86_cpu_type): Enable function. 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; diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c index d65acac..5267474 100644 --- a/linux/dev/glue/block.c +++ b/linux/dev/glue/block.c @@ -354,22 +354,17 @@ struct buffer_head * getblk (kdev_t dev, int block, int size) { struct buffer_head *bh; - static struct buffer_head bhead; assert (size <= PAGE_SIZE); - if (! linux_auto_config) - bh = (struct buffer_head *) kalloc (sizeof (struct buffer_head)); - else - bh = &bhead; + bh = (struct buffer_head *) kalloc (sizeof (struct buffer_head)); if (bh) { memset (bh, 0, sizeof (struct buffer_head)); bh->b_data = alloc_buffer (size); if (! bh->b_data) { - if (! linux_auto_config) - kfree ((vm_offset_t) bh, sizeof (struct buffer_head)); + kfree ((vm_offset_t) bh, sizeof (struct buffer_head)); return NULL; } bh->b_dev = dev; @@ -385,8 +380,7 @@ void __brelse (struct buffer_head *bh) { free_buffer (bh->b_data, bh->b_size); - if (! linux_auto_config) - kfree ((vm_offset_t) bh, sizeof (*bh)); + kfree ((vm_offset_t) bh, sizeof (*bh)); } /* Allocate a buffer of SIZE bytes and fill it with data |