diff options
author | alc <alc@FreeBSD.org> | 2003-12-31 01:44:45 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2003-12-31 01:44:45 +0000 |
commit | e11aa2c75c2d358949bc563948b3a2525e933560 (patch) | |
tree | cbd7e4891b4411f14dfaf472647fb2479abbb7f4 /sys/vm/vm_page.c | |
parent | 142bfff509a3ae5642a3344e83210a7ee32b02dd (diff) | |
download | FreeBSD-src-e11aa2c75c2d358949bc563948b3a2525e933560.zip FreeBSD-src-e11aa2c75c2d358949bc563948b3a2525e933560.tar.gz |
Simplify vm_page_grab(): Don't bother with the generation check. If the
vm object hasn't changed, the desired page will be at or near the root
of the vm object's splay tree, making vm_page_lookup() cheap. (The only
lock required for vm_page_lookup() is already held.) If, however, the
vm object has changed and retry was requested, eliminating the generation
check also eliminates a pointless acquisition and release of the page
queues lock.
Diffstat (limited to 'sys/vm/vm_page.c')
-rw-r--r-- | sys/vm/vm_page.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 9290a6a..af8a594 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1432,30 +1432,18 @@ vm_page_t vm_page_grab(vm_object_t object, vm_pindex_t pindex, int allocflags) { vm_page_t m; - int s, generation; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); retrylookup: if ((m = vm_page_lookup(object, pindex)) != NULL) { vm_page_lock_queues(); if (m->busy || (m->flags & PG_BUSY)) { - generation = object->generation; - - s = splvm(); - while ((object->generation == generation) && - (m->busy || (m->flags & PG_BUSY))) { - vm_page_flag_set(m, PG_WANTED | PG_REFERENCED); - VM_OBJECT_UNLOCK(object); - msleep(m, &vm_page_queue_mtx, PDROP | PVM, "pgrbwt", 0); - VM_OBJECT_LOCK(object); - if ((allocflags & VM_ALLOC_RETRY) == 0) { - splx(s); - return NULL; - } - vm_page_lock_queues(); - } - vm_page_unlock_queues(); - splx(s); + vm_page_flag_set(m, PG_WANTED | PG_REFERENCED); + VM_OBJECT_UNLOCK(object); + msleep(m, &vm_page_queue_mtx, PDROP | PVM, "pgrbwt", 0); + VM_OBJECT_LOCK(object); + if ((allocflags & VM_ALLOC_RETRY) == 0) + return (NULL); goto retrylookup; } else { if (allocflags & VM_ALLOC_WIRED) |