From 625e6c0af438e8ec67de33aecea4e9cc4cdb16f9 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 17 Feb 2006 21:02:39 +0000 Subject: Expand scope of marker to reduce the number of page queue scan restarts. --- sys/vm/vm_pageout.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'sys/vm') diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index b5abcebab38d..e7611d2d0c4a 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -905,6 +905,16 @@ rescan0: continue; } + /* + * Following operations may unlock + * vm_page_queue_mtx, invalidating the 'next' + * pointer. To prevent an inordinate number + * of restarts we use our marker to remember + * our place. + * + */ + TAILQ_INSERT_AFTER(&vm_page_queues[PQ_INACTIVE].pl, + m, &marker, pageq); /* * The object is already known NOT to be dead. It * is possible for the vget() to block the whole @@ -936,8 +946,8 @@ rescan0: ++pageout_lock_miss; if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; - VM_OBJECT_UNLOCK(object); - continue; + vp = NULL; + goto unlock_and_continue; } vm_page_unlock_queues(); VI_LOCK(vp); @@ -950,8 +960,8 @@ rescan0: vn_finished_write(mp); if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; - VM_OBJECT_UNLOCK(object); - continue; + vp = NULL; + goto unlock_and_continue; } VM_OBJECT_LOCK(object); vm_page_lock_queues(); @@ -964,7 +974,8 @@ rescan0: */ if (VM_PAGE_GETQUEUE(m) != PQ_INACTIVE || m->object != object || - object->handle != vp) { + object->handle != vp || + TAILQ_NEXT(m, pageq) != &marker) { if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; goto unlock_and_continue; @@ -998,21 +1009,14 @@ rescan0: * laundry. If it is still in the laundry, then we * start the cleaning operation. * - * This operation may cluster, invalidating the 'next' - * pointer. To prevent an inordinate number of - * restarts we use our marker to remember our place. - * * decrement page_shortage on success to account for * the (future) cleaned page. Otherwise we could wind * up laundering or cleaning too many pages. */ - TAILQ_INSERT_AFTER(&vm_page_queues[PQ_INACTIVE].pl, m, &marker, pageq); if (vm_pageout_clean(m) != 0) { --page_shortage; --maxlaunder; } - next = TAILQ_NEXT(&marker, pageq); - TAILQ_REMOVE(&vm_page_queues[PQ_INACTIVE].pl, &marker, pageq); unlock_and_continue: VM_OBJECT_UNLOCK(object); if (vp) { @@ -1021,6 +1025,9 @@ unlock_and_continue: vn_finished_write(mp); vm_page_lock_queues(); } + next = TAILQ_NEXT(&marker, pageq); + TAILQ_REMOVE(&vm_page_queues[PQ_INACTIVE].pl, + &marker, pageq); continue; } VM_OBJECT_UNLOCK(object); -- cgit v1.3