From cf060942dbe0b150eee1803047d438950fa8c5f0 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 28 Sep 2017 17:55:41 +0000 Subject: [PATCH] Optimize vm_object_page_remove() by eliminating pointless calls to pmap_remove_all(). If the object to which a page belongs has no references, then that page cannot possibly be mapped. Reviewed by: kib MFC after: 1 week --- sys/vm/vm_object.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index fe015bdb8776..270477e57405 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1990,7 +1990,8 @@ vm_object_page_remove(vm_object_t object, vm_pindex_t start, vm_pindex_t end, goto again; } if (p->wire_count != 0) { - if ((options & OBJPR_NOTMAPPED) == 0) + if ((options & OBJPR_NOTMAPPED) == 0 && + object->ref_count != 0) pmap_remove_all(p); if ((options & OBJPR_CLEANONLY) == 0) { p->valid = 0; @@ -2007,12 +2008,13 @@ vm_object_page_remove(vm_object_t object, vm_pindex_t start, vm_pindex_t end, KASSERT((p->flags & PG_FICTITIOUS) == 0, ("vm_object_page_remove: page %p is fictitious", p)); if ((options & OBJPR_CLEANONLY) != 0 && p->valid != 0) { - if ((options & OBJPR_NOTMAPPED) == 0) + if ((options & OBJPR_NOTMAPPED) == 0 && + object->ref_count != 0) pmap_remove_write(p); - if (p->dirty) + if (p->dirty != 0) continue; } - if ((options & OBJPR_NOTMAPPED) == 0) + if ((options & OBJPR_NOTMAPPED) == 0 && object->ref_count != 0) pmap_remove_all(p); p->flags &= ~PG_ZERO; if (vm_page_free_prep(p, false))