diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2014-01-13 21:26:00 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2014-01-15 16:37:24 -0600 |
commit | 572436a77d7de6e4bc783ff7e23f48838b141b33 (patch) | |
tree | bbdbc13126360edb64b6ec00c9a7bdb733c196ca /src/kernel/heapmgr.C | |
parent | 1519b0b4786367a4855edfd24844b896293d5d80 (diff) | |
download | talos-hostboot-572436a77d7de6e4bc783ff7e23f48838b141b33.tar.gz talos-hostboot-572436a77d7de6e4bc783ff7e23f48838b141b33.zip |
Improve robustness of 'free' flag in HeapMgr.
Change-Id: Iea61e36289410540710ced9bb0098c3fadc4e6a4
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/8055
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/kernel/heapmgr.C')
-rw-r--r-- | src/kernel/heapmgr.C | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/kernel/heapmgr.C b/src/kernel/heapmgr.C index 4fdfded57..d09799a72 100644 --- a/src/kernel/heapmgr.C +++ b/src/kernel/heapmgr.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2010,2013 */ +/* COPYRIGHT International Business Machines Corp. 2010,2014 */ /* */ /* p1 */ /* */ @@ -119,8 +119,8 @@ void* HeapManager::_allocate(size_t i_sz) g_smallheap_alloc_hw = g_smallheap_allocated; // test_pages(); #endif - crit_assert(chunk->free); - chunk->free = false; + crit_assert(chunk->free == 'F'); + chunk->free = '\0'; return &chunk->next; } } @@ -197,7 +197,7 @@ void HeapManager::_free(void * i_ptr) __sync_sub_and_fetch(&g_smallheap_count,1); __sync_sub_and_fetch(&g_smallheap_allocated,bucketByteSize(chunk->bucket)); #endif - crit_assert(!chunk->free); + crit_assert(chunk->free != 'F'); push_bucket(chunk, chunk->bucket); } } @@ -240,7 +240,7 @@ HeapManager::chunk_t* HeapManager::pop_bucket(size_t i_bucket) void HeapManager::push_bucket(chunk_t* i_chunk, size_t i_bucket) { if (i_bucket >= BUCKETS) return; - i_chunk->free = true; + i_chunk->free = 'F'; first_chunk[i_bucket].push(i_chunk); } @@ -330,10 +330,10 @@ void HeapManager::_coalesce() chunk = NULL; while(NULL != (chunk = first_chunk[bucket].pop())) { - kassert(chunk->free); + kassert(chunk->free == 'F'); chunk->next = head; - chunk->coalesce = true; + chunk->coalesce = 'C'; head = chunk; } } @@ -354,7 +354,7 @@ void HeapManager::_coalesce() { // This chunk might already be combined with a chunk earlier // in the loop. - if((!chunk->coalesce) || (!chunk->free)) + if((chunk->coalesce != 'C') || (chunk->free != 'F')) { break; } @@ -373,7 +373,7 @@ void HeapManager::_coalesce() } // Cannot merge if buddy is not free. - if ((!buddy->free) || (!buddy->coalesce)) + if ((buddy->free != 'F') || (buddy->coalesce != 'C')) { break; } @@ -390,7 +390,7 @@ void HeapManager::_coalesce() } // Do merge. - buddy->free = buddy->coalesce = false; + buddy->free = '\0'; buddy->coalesce = '\0'; chunk->bucket = newBucket; incrementChunk = false; mergedChunks = true; @@ -410,7 +410,7 @@ void HeapManager::_coalesce() chunk = head; while (NULL != chunk) { - if ((chunk->free) && (chunk->coalesce)) + if ((chunk->free == 'F') && (chunk->coalesce == 'C')) { chunk_t* temp = chunk->next; chunk->next = newHead; @@ -437,7 +437,7 @@ void HeapManager::_coalesce() { chunk_t * temp = chunk->next; - chunk->coalesce = false; + chunk->coalesce = '\0'; push_bucket(chunk,chunk->bucket); ++cv_free_chunks; |