diff options
author | H. Peter Anvin <hpa@zytor.com> | 2001-10-18 18:14:53 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2001-10-18 18:14:53 +0000 |
commit | 579d4257024dc37f41439f268cc6bb815ada84db (patch) | |
tree | 419722105743854a5ba75df8a521b32df07ed8b1 | |
parent | 05bccefa7306165bb1c36f469f429500e0e6f919 (diff) | |
download | lpsm-579d4257024dc37f41439f268cc6bb815ada84db.tar.gz lpsm-579d4257024dc37f41439f268cc6bb815ada84db.tar.xz lpsm-579d4257024dc37f41439f268cc6bb815ada84db.zip |
Make test a little saner. Add debugging output listing the available
buddies when compiling with debugging on.
-rw-r--r-- | alloc.c | 40 | ||||
-rw-r--r-- | testrecovery.c | 2 |
2 files changed, 41 insertions, 1 deletions
@@ -230,6 +230,45 @@ static int find_set_bit(const void *ptr, int start, int count, int err) static struct ObjStore *os; static struct arena_header *ah; + +#ifndef NDEBUG +/* + * Debugging routine to print the number of allocations of each size + */ +void buddy_count(void) +{ + int i, o, obit, ebit, xbit; + int fcount, acount; + unsigned long bt = 0, bf = 0, ba = 0; + + for ( i = 0, o = ah->arena_size_lg2 ; + o >= BUDDY_ORDER_MIN ; + i++, o-- ) { + obit = 1 << i; + ebit = obit << 1; + fcount = acount = 0; + for ( xbit = obit ; xbit < ebit ; xbit++ ) { + if ( test_bit(ah->free_bitmap, xbit) ) + fcount++; + } + for ( xbit = obit ; xbit < ebit ; xbit++ ) { + if ( test_bit(ah->alloc_bitmap, xbit) ) + acount++; + } + + DPRINTF((" rorder %2d order %2d free %8d used %8d\n", + i, ah->arena_size_lg2-i, fcount, acount)); + + bt += (fcount+acount) * (1UL << o); + bf += fcount * (1UL << o); + ba += acount * (1UL << o); + } + DPRINTF((" bytes: %lu free, %lu allocated, %lu total\n", + bf, ba, bt)); +} +#else +#define buddy_count() ((void)0) +#endif /* * Initalize the object store arena allocator. This returns NULL @@ -465,6 +504,7 @@ static void *objstore_malloc_buddy(size_t size) xbit = objstore_find_free_chunk(rorder); if ( !xbit ) { /* Need to extend */ + buddy_count(); /* DEBUG */ if ( objstore_extend_arena(ah->arena_size_lg2 + 1) ) return NULL; /* Failed to extend */ } diff --git a/testrecovery.c b/testrecovery.c index 262a95b..0dbe66c 100644 --- a/testrecovery.c +++ b/testrecovery.c @@ -33,7 +33,7 @@ #include "objstore.h" #define COUNT 262144 -#define SLOTS 65536 +#define SLOTS 4096 #define MAXLOG 26 void **areas; |