allocate_page_run(): Use temporary lists to store the pages we're allocating.

This makes appending the pages to the active queue more efficient and we
don't need the vm_page::is_cleared bit anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35011 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-01-11 16:36:31 +00:00
parent a0b07ebaab
commit d7455de2f6
2 changed files with 13 additions and 18 deletions

View File

@ -96,11 +96,8 @@ struct vm_page {
uint8 type : 2;
uint8 state : 3;
uint8 is_cleared : 1;
// is currently only used in vm_page_allocate_page_run()
uint8 busy_writing : 1;
uint8 unused : 1;
uint8 unused : 2;
// used in VMAnonymousCache::Merge()
int8 usage_count;

View File

@ -2189,39 +2189,37 @@ allocate_page_run(page_num_t start, page_num_t length, int pageState,
T(AllocatePageRun(length));
// pull the pages out of the appropriate queues
VMPageQueue::PageList freePages;
VMPageQueue::PageList clearPages;
for (page_num_t i = 0; i < length; i++) {
vm_page& page = sPages[start + i];
DEBUG_PAGE_ACCESS_START(&page);
if (page.state == PAGE_STATE_CLEAR) {
page.is_cleared = true;
sClearPageQueue.Remove(&page);
clearPages.Add(&page);
} else {
page.is_cleared = false;
sFreePageQueue.Remove(&page);
freePages.Add(&page);
}
page.state = PAGE_STATE_BUSY;
page.usage_count = 1;
}
freeClearQueueLocker.Unlock();
// add the pages to the active queue
for (page_num_t i = 0; i < length; i++) {
vm_page& page = sPages[start + i];
sActivePageQueue.AppendUnlocked(&page);
// TODO: We could do this more efficiently, if we used a temporary
// on-stack queue and added all pages at once.
page.usage_count = 1;
}
// clear pages, if requested
if (pageState == PAGE_STATE_CLEAR) {
for (page_num_t i = 0; i < length; i++) {
if (!sPages[start + i].is_cleared)
clear_page(&sPages[start + i]);
for (VMPageQueue::PageList::Iterator it = freePages.GetIterator();
vm_page* page = it.Next();) {
clear_page(page);
}
}
// add pages to active queue
freePages.MoveFrom(&clearPages);
sActivePageQueue.AppendUnlocked(freePages, length);
// Note: We don't unreserve the pages since we pulled them out of the
// free/clear queues without adjusting sUnreservedFreePages.