summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_page.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2003-06-26 15:44:03 +0000
committeralc <alc@FreeBSD.org>2003-06-26 15:44:03 +0000
commit0e0026d70fe8096ec736ef6a6d998978587fcef3 (patch)
tree1c874e3616d90d1016ccfc5096ffd1eab8e786d5 /sys/vm/vm_page.c
parentf0e747489fbed5a08eb65f7eb8a2179b63fe288e (diff)
downloadFreeBSD-src-0e0026d70fe8096ec736ef6a6d998978587fcef3.zip
FreeBSD-src-0e0026d70fe8096ec736ef6a6d998978587fcef3.tar.gz
vm_page_select_cache() enforces a number of conditions on the returned
page. Add the ability to lock the containing object to those conditions.
Diffstat (limited to 'sys/vm/vm_page.c')
-rw-r--r--sys/vm/vm_page.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index ac13102..ac3cccc 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -719,7 +719,8 @@ vm_page_select_cache(vm_pindex_t color)
while (TRUE) {
m = vm_pageq_find(PQ_CACHE, color & PQ_L2_MASK, FALSE);
if (m && ((m->flags & (PG_BUSY|PG_UNMANAGED)) || m->busy ||
- m->hold_count || m->wire_count)) {
+ m->hold_count || m->wire_count ||
+ !VM_OBJECT_TRYLOCK(m->object))) {
vm_page_deactivate(m);
continue;
}
@@ -765,6 +766,7 @@ vm_page_select_free(vm_pindex_t color, boolean_t prefer_zero)
vm_page_t
vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int req)
{
+ vm_object_t m_object;
vm_page_t m = NULL;
vm_pindex_t color;
int flags, page_req, s;
@@ -820,10 +822,13 @@ loop:
return (NULL);
}
KASSERT(m->dirty == 0, ("Found dirty cache page %p", m));
+ m_object = m->object;
+ VM_OBJECT_LOCK_ASSERT(m_object, MA_OWNED);
vm_page_busy(m);
pmap_remove_all(m);
vm_page_free(m);
vm_page_unlock_queues();
+ VM_OBJECT_UNLOCK(m_object);
goto loop;
} else {
/*
OpenPOWER on IntegriCloud