The page thief can now also steal active pages under pressure.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22456 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-10-06 11:38:03 +00:00
parent 0e18334057
commit 1211351476
+9 -10
View File
@@ -760,7 +760,7 @@ page_thief(void* /*unused*/)
//dprintf("page thief running - target %ld...\n", steal); //dprintf("page thief running - target %ld...\n", steal);
vm_page* page = NULL; vm_page* page = NULL;
bool stealActive = false; bool stealActive = false, desperate = false;
InterruptsSpinLocker locker(sPageLock); InterruptsSpinLocker locker(sPageLock);
while (steal > 0) { while (steal > 0) {
@@ -790,9 +790,10 @@ page_thief(void* /*unused*/)
break; break;
// when memory is really low, we really want pages // when memory is really low, we really want pages
if (stealActive) if (stealActive) {
score = 127; score = 127;
else { desperate = true;
} else {
stealActive = true; stealActive = true;
score = 5; score = 5;
steal = 5; steal = 5;
@@ -841,13 +842,11 @@ page_thief(void* /*unused*/)
if (!cacheLocker.IsLocked()) if (!cacheLocker.IsLocked())
continue; continue;
if (page->state != PAGE_STATE_INACTIVE) { // check again if that page is still a candidate
// TODO: if this is an active page (as in stealActive), we need if (page->state != PAGE_STATE_INACTIVE
// to unmap it and check if it's modified in an atomic operation. && (!stealActive || page->state != PAGE_STATE_ACTIVE
// For now, we'll just ignore it, even though this might let || page->wired_count != 0))
// vm_page_allocate_page() wait forever...
continue; continue;
}
// recheck eventual last minute changes // recheck eventual last minute changes
uint32 flags; uint32 flags;
@@ -856,7 +855,7 @@ page_thief(void* /*unused*/)
// page was modified, don't steal it // page was modified, don't steal it
vm_page_set_state(page, PAGE_STATE_MODIFIED); vm_page_set_state(page, PAGE_STATE_MODIFIED);
continue; continue;
} else if ((flags & PAGE_ACCESSED) != 0) { } else if ((flags & PAGE_ACCESSED) != 0 && !desperate) {
// page is in active use, don't steal it // page is in active use, don't steal it
vm_page_set_state(page, PAGE_STATE_ACTIVE); vm_page_set_state(page, PAGE_STATE_ACTIVE);
continue; continue;