diff --git a/src/kernel/vm2/area.C b/src/kernel/vm2/area.C index 6acc6e625a..df7fbd570e 100644 --- a/src/kernel/vm2/area.C +++ b/src/kernel/vm2/area.C @@ -50,7 +50,7 @@ unsigned long area::mapAddressSpecToAddress(addressSpec type,void * req,int page } status_t area::createAreaGuts( char *inName, int pageCount, void **address, addressSpec type, pageState inState, protectType protect, bool inFinalWrite, int fd, size_t offset, area *originalArea=NULL /* For clone only*/) { - error ("area::createAreaGuts : name = %s, pageCount = %d, address = %ld, addressSpec = %d, pageState = %d, protection = %d, inFinalWrite = %d, fd = %d, offset = %d,originalArea=%ld\n", + error ("area::createAreaGuts : name = %s, pageCount = %d, address = %lx, addressSpec = %d, pageState = %d, protection = %d, inFinalWrite = %d, fd = %d, offset = %d,originalArea=%ld\n", inName,pageCount,address,type,inState,protect,inFinalWrite,fd,offset,originalArea); strcpy(name,inName); vpage *newPage; diff --git a/src/kernel/vm2/areaManager.C b/src/kernel/vm2/areaManager.C index 2b92b2eee1..6eda707c2d 100644 --- a/src/kernel/vm2/areaManager.C +++ b/src/kernel/vm2/areaManager.C @@ -139,7 +139,7 @@ long areaManager::nextAreaID=0; int areaManager::createArea(char *AreaName,int pageCount,void **address, addressSpec addType,pageState state,protectType protect) { - error ("Creating an area\n"); + error ("areaManager::createArea - Creating an area\n"); lock(); area *newArea = new (vmBlock->areaPool->get()) area; error ("areaManager::createArea - got a new area (%p) from the areaPool\n",newArea); @@ -155,7 +155,7 @@ int areaManager::createArea(char *AreaName,int pageCount,void **address, address int retVal=newArea->getAreaID(); error ("areaManager::createArea - new area id found\n"); unlock(); - error ("Done Creating an area\n"); + error ("areaManager::createArea - Done Creating an area\n"); return retVal; } diff --git a/src/kernel/vm2/areaPool.C b/src/kernel/vm2/areaPool.C index baae449062..917b9c2172 100644 --- a/src/kernel/vm2/areaPool.C +++ b/src/kernel/vm2/areaPool.C @@ -23,8 +23,8 @@ area *poolarea::get(void) } else { - //error ("poolarea::get: Getting a new page!\n"); page *newPage=vmBlock->pageMan->getPage(); + error ("poolarea::get: Getting new page %lx!\n",newPage->getAddress()); if (!newPage) throw ("Out of pages to allocate a pool!"); int newCount=PAGE_SIZE/sizeof(area); diff --git a/src/kernel/vm2/hashTable.h b/src/kernel/vm2/hashTable.h index 5020ae5c35..cdaa9c8234 100644 --- a/src/kernel/vm2/hashTable.h +++ b/src/kernel/vm2/hashTable.h @@ -20,22 +20,28 @@ class hashTable : public list nodeCount=0; numRocks=size; - error ("Starting to initalize hash table\n"); + //error ("Starting to initalize hash table\n"); if (size*sizeof (list *)>PAGE_SIZE) throw ("Hash table too big!"); - error ("Getting Page\n"); + //error ("Getting Page\n"); + + // Get the block for the page of pointers page *newPage=vmBlock->pageMan->getPage(); - error ("Got Page\n"); - if (!newPage) + error ("hashTable::hashTable - Got Page %x\n",newPage); + if (!newPage) { + error ("Out of pages to allocate a pool! newPage = %x\n",newPage); throw ("Out of pages to allocate a pool!"); + } rocks=(list **)(newPage->getAddress()); - error ("Got rocks\n"); + //error ("Got rocks\n"); int listsPerPage=PAGE_SIZE/sizeof(list); int pages=(size+(listsPerPage-1))/listsPerPage; for (int pageCount=0;pageCountpageMan->getPage(); + error ("hashTable::hashTable - Got Page %x\n",newPage); if (!newPage) throw ("Out of pages to allocate a pool!"); for (int i=0;izero(); } // This could fail if someone swooped in and stole our page. } + error ("pageManager::getPage - returning page %x, clean = %d, unused = %d, inuse = %x\n",ret,clean.count(),unused.count(),inUse.count()); acquire_sem(inUseLock); inUse.add(ret); release_sem(inUseLock); ret->count++; + if (!ret) + throw ("Out of physical pages!"); return ret; } @@ -79,12 +83,16 @@ bool pageManager::getContiguousPages(int pages,page **location) { } void pageManager::freePage(page *toFree) { + error ("pageManager::freePage; count = %d, address = %p\n",toFree->count,toFree); if (atomic_add(&(toFree->count),-1)==1) { // atomic_add returns the *PREVIOUS* value. So we need to check to see if the one we are wasting was the last one. acquire_sem(inUseLock); inUse.remove(toFree); + inUse.dump(); release_sem(inUseLock); + acquire_sem(unusedLock); unused.add(toFree); + unused.dump(); release_sem(unusedLock); } } diff --git a/src/kernel/vm2/simpleTest.C b/src/kernel/vm2/simpleTest.C index a48672a182..6ae58a48b3 100644 --- a/src/kernel/vm2/simpleTest.C +++ b/src/kernel/vm2/simpleTest.C @@ -5,18 +5,17 @@ #include #include -vmInterface vm(30); +vmInterface *vm; -void writeByte(unsigned long addr,unsigned int offset, char value) { vm.setByte(addr+offset,value); } -unsigned char readByte(unsigned long addr,unsigned int offset ) { char value=vm.getByte(addr+offset); return value; } +void writeByte(unsigned long addr,unsigned int offset, char value) { vm->setByte(addr+offset,value); } +unsigned char readByte(unsigned long addr,unsigned int offset ) { char value=vm->getByte(addr+offset); return value; } int createFillAndTest(int pages,char *name) { - try{ unsigned long addr; int area1; error ("%s: createFillAndTest: about to create \n",name); - area1=vm.createArea(name,pages,(void **)(&addr)); + area1=vm->createArea(name,pages,(void **)(&addr)); error ("%s: createFillAndTest: create done\n",name); for (int i=0;ipageMan->getPage(); + error ("poolvnode::get: Getting new page %lx!\n",newPage->getAddress()); if (!newPage) throw ("Out of pages to allocate a pool!"); int newCount=PAGE_SIZE/sizeof(vnode); diff --git a/src/kernel/vm2/vpage.C b/src/kernel/vm2/vpage.C index f15e23d6c8..27fb8ba77f 100644 --- a/src/kernel/vm2/vpage.C +++ b/src/kernel/vm2/vpage.C @@ -48,8 +48,10 @@ void vpage::setup(unsigned long start,vnode *backing, page *physMem,protectType } else backingNode=&(vmBlock->swapMan->findNode()); - if (!physMem && (state!=LAZY) && (state!=NO_LOCK)) + if (!physMem && (state!=LAZY) && (state!=NO_LOCK)) { physPage=vmBlock->pageMan->getPage(); + error ("vpage::setup, state = %d, allocated page %x\n",state,physPage); + } else { if (physMem) atomic_add(&(physMem->count),1); @@ -60,8 +62,10 @@ void vpage::setup(unsigned long start,vnode *backing, page *physMem,protectType } void vpage::cleanup(void) { - if (physPage) // Note that free means release one reference + if (physPage) { // Note that free means release one reference + error ("vpage::cleanup, freeing physcal page %x\n",physPage); vmBlock->pageMan->freePage(physPage); + } if (backingNode) { if (backingNode->fd) if (backingNode->fd==vmBlock->swapMan->getFD()) @@ -85,8 +89,7 @@ bool vpage::fault(void *fault_address, bool writeError) { dirty=true; if (protection==copyOnWrite) { // Else, this was just a "let me know when I am dirty"... page *newPhysPage=vmBlock->pageMan->getPage(); - if (!newPhysPage) // No room at the inn - return false; + error ("vpage::fault - copy on write allocated page %x\n",newPhysPage); memcpy((void *)(newPhysPage->getAddress()),(void *)(physPage->getAddress()),PAGE_SIZE); physPage=newPhysPage; protection=writable; @@ -96,6 +99,7 @@ bool vpage::fault(void *fault_address, bool writeError) { return true; } physPage=vmBlock->pageMan->getPage(); + error ("vpage::fault - regular - allocated page %x\n",physPage); if (!physPage) // No room at the inn return false; error ("vpage::fault: New page allocated! new physical address = %x vnode.fd=%d, vnode.offset=%d, \n",physPage->getAddress(),((backingNode)?backingNode->fd:0),((backingNode)?backingNode->offset:0)); diff --git a/src/kernel/vm2/vpagePool.C b/src/kernel/vm2/vpagePool.C index 15b58f8f3f..6de305e5a2 100644 --- a/src/kernel/vm2/vpagePool.C +++ b/src/kernel/vm2/vpagePool.C @@ -22,8 +22,8 @@ vpage *poolvpage::get(void) } else { - //error ("poolvpage::get: Getting a new page!\n"); page *newPage=vmBlock->pageMan->getPage(); + error ("poolvpage::get: Getting new page %lx!\n",newPage->getAddress()); if (!newPage) throw ("Out of pages to allocate a pool!"); int newCount=PAGE_SIZE/sizeof(vpage);