summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorups <ups@FreeBSD.org>2006-02-15 22:29:53 +0000
committerups <ups@FreeBSD.org>2006-02-15 22:29:53 +0000
commitad011f6a36d4d13210e325ce8c3e5930c94dff78 (patch)
tree6e69f574d170d437b38db366fbf114feda9a1d32
parent538bfdf89a075d1e95332eb7ffd5561900da4ca9 (diff)
downloadFreeBSD-src-ad011f6a36d4d13210e325ce8c3e5930c94dff78.zip
FreeBSD-src-ad011f6a36d4d13210e325ce8c3e5930c94dff78.tar.gz
When the VM needs to allocated physical memory pages (for non interrupt use)
and it has not plenty of free pages it tries to free pages in the cache queue. Unfortunately freeing a cached page requires the locking of the object that owns the page. However in the context of allocating pages we may not be able to lock the object and thus can only TRY to lock the object. If the locking try fails the cache page can not be freed and is activated to move it out of the way so that we may try to free other cache pages. If all pages in the cache belong to objects that are currently locked the cache queue can be emptied without freeing a single page. This scenario caused two problems: 1) vm_page_alloc always failed allocation when it tried freeing pages from the cache queue and failed to do so. However if there are more than cnt.v_interrupt_free_min pages on the free list it should return pages when requested with priority VM_ALLOC_SYSTEM. Failure to do so can cause resource exhaustion deadlocks. 2) Threads than need to allocate pages spend a lot of time cleaning up the page queue without really getting anything done while the pagedaemon needs to work overtime to refill the cache. This change fixes the first problem. (1) Reviewed by: tegge@
-rw-r--r--sys/vm/vm_page.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index caf9125..fc2f29a 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -815,10 +815,20 @@ loop:
vm_page_unlock_queues();
atomic_add_int(&vm_pageout_deficit, 1);
pagedaemon_wakeup();
- return (NULL);
+
+ if (page_req != VM_ALLOC_SYSTEM)
+ return NULL;
+
+ mtx_lock_spin(&vm_page_queue_free_mtx);
+ if (cnt.v_free_count <= cnt.v_interrupt_free_min) {
+ mtx_unlock_spin(&vm_page_queue_free_mtx);
+ return (NULL);
+ }
+ m = vm_pageq_find(PQ_FREE, color, (req & VM_ALLOC_ZERO) != 0);
+ } else {
+ vm_page_unlock_queues();
+ goto loop;
}
- vm_page_unlock_queues();
- goto loop;
} else {
/*
* Not allocatable from cache from interrupt, give up.
OpenPOWER on IntegriCloud