From: jzhou Date: Fri, 5 Aug 2011 22:04:07 +0000 (+0000) Subject: Bug fix: during gc compact, one block's usage information could be modified by multip... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6035a6e556209b48ab78b197294aaf27c89ca0c4;p=IRC.git Bug fix: during gc compact, one block's usage information could be modified by multiple cores, should avoid mis-overwriting the correct information due to the bad incoming order of GCRETURNMEM messages --- diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.c b/Robust/src/Runtime/bamboo/multicoregccompact.c index d1457a47..d0adbc6f 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.c +++ b/Robust/src/Runtime/bamboo/multicoregccompact.c @@ -58,25 +58,28 @@ void handleReturnMem_I(unsigned int cnum, void *heaptop) { struct blockrecord * blockrecord=&allocationinfo.blocktable[blockindex]; - blockrecord->status=BS_FREE; - blockrecord->usedspace=(unsigned INTPTR)(heaptop-OFFSET2BASEVA(blockindex)-gcbaseva); - blockrecord->freespace=BLOCKSIZE(localblocknum)-blockrecord->usedspace; - /* Update the lowest free block */ - if (blockindex < allocationinfo.lowestfreeblock) { - allocationinfo.lowestfreeblock=blockindex; - } + unsigned INTPTR newusedspace=(unsigned INTPTR)(heaptop-OFFSET2BASEVA(blockindex)-gcbaseva); + if(blockrecord->usedspace < newusedspace) { + blockrecord->status=BS_FREE; + blockrecord->usedspace=newusedspace; + blockrecord->freespace=BLOCKSIZE(localblocknum)-blockrecord->usedspace; + /* Update the lowest free block */ + if (blockindex < allocationinfo.lowestfreeblock) { + allocationinfo.lowestfreeblock=blockindex; + } - /* This is our own block...means we should mark other blocks above us as free*/ - - if (cnum==blockrecord->corenum) { - unsigned INTPTR nextlocalblocknum=localblocknum+1; - for(;nextlocalblocknumstatus=BS_FREE; - nextblockrecord->usedspace=0; - //this is true because this cannot be the lowest block - nextblockrecord->freespace=BLOCKSIZE(1); + /* This is our own block...means we should mark other blocks above us as free*/ + + if (cnum==blockrecord->corenum) { + unsigned INTPTR nextlocalblocknum=localblocknum+1; + for(;nextlocalblocknumstatus=BS_FREE; + nextblockrecord->usedspace=0; + //this is true because this cannot be the lowest block + nextblockrecord->freespace=BLOCKSIZE(1); + } } } @@ -570,6 +573,7 @@ void master_compact() { while(!gc_checkCoreStatus()) ; +// GC_CACHE_COHERENT_ON should be true for gcmappingtbl, and the gcmappingtbl should be zeroed out before starting gc #ifdef GC_DEBUG void *nextvalid=gcbaseva; for(void *tmp=gcbaseva; tmp(gcbaseva+BAMBOO_SHARED_MEM_SIZE))) tprintf("Bad pointer %x in line %u\n",marktmpptr, __LINE__); }} +//#define MARKOBJ(objptr) {void * marktmpptr=objptr; if (marktmpptr!=NULL) {markObj(marktmpptr);if ((marktmpptr(gcbaseva+BAMBOO_SHARED_MEM_SIZE))) tprintf("Bad pointer %x in line %u\n",marktmpptr, __LINE__); }} #define MARKOBJ(objptr) {void * marktmpptr=objptr; if (marktmpptr!=NULL) {markObj(marktmpptr);}} @@ -259,10 +259,10 @@ void mark(struct garbagelist * stackptr) { if (unit!=iunits) { tprintf("Bad mark on %x %u!=%u\n", ptr, unit, iunits); tprintf("hibits=%x lobits=%x\n", hibits, lobits); - tprintf("ohigh=%x olow=%x", ohigh, olow); + tprintf("ohigh=%x olow=%x\n", ohigh, olow); unsigned INTPTR nhigh=gcmarktbl[hibits]; unsigned INTPTR nlow=gcmarktbl[hibits+1]; - tprintf("nhigh=%x nlow=%x", nhigh, nlow); + tprintf("nhigh=%x nlow=%x\n", nhigh, nlow); } #endif if(islarge) {