mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
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.
This commit is contained in:
parent
279b7e129f
commit
bcdaad7fe7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124012
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user