Avoid dequeuing the fault page during a soft fault.

Such pages are re-enqueued at the end of the fault handler, preserving
LRU. Rather than performing two separate operations per fault, simply
requeue the page at the end of the fault (or bump its activation count
if it resides in PQ_ACTIVE, avoiding the page queue lock entirely).
This elides some page lock and page queue lock operations in common
cases, e.g., CoW faults.

Note that we must still dequeue the source page for "optimized" CoW
faults since the page may not remain enqueued while it is moved to
another object.

Reviewed by:	alc, kib
Tested by:	pho
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14625
This commit is contained in:
Mark Johnston 2018-03-18 16:49:30 +00:00
parent 0eb50f9cd2
commit c6a70eaea8

View File

@ -682,7 +682,7 @@ RetryFault:;
/*
* Reference the page before unlocking and
* sleeping so that the page daemon is less
* likely to reclaim it.
* likely to reclaim it.
*/
vm_page_aflag_set(fs.m, PGA_REFERENCED);
if (fs.object != fs.first_object) {
@ -710,9 +710,6 @@ RetryFault:;
vm_object_deallocate(fs.first_object);
goto RetryFault;
}
vm_page_lock(fs.m);
vm_page_remque(fs.m);
vm_page_unlock(fs.m);
/*
* Mark page busy for other processes, and the
@ -723,7 +720,7 @@ RetryFault:;
vm_page_xbusy(fs.m);
if (fs.m->valid != VM_PAGE_BITS_ALL)
goto readrest;
break;
break; /* break to PAGE HAS BEEN FOUND */
}
KASSERT(fs.m == NULL, ("fs.m should be NULL, not %p", fs.m));
@ -1105,6 +1102,7 @@ readrest:
*/
fs.object == fs.first_object->backing_object) {
vm_page_lock(fs.m);
vm_page_remque(fs.m);
vm_page_remove(fs.m);
vm_page_unlock(fs.m);
vm_page_lock(fs.first_m);