svn commit: r323973 - head/sys/vm
Alan Cox
alc at FreeBSD.org
Sun Sep 24 16:50:11 UTC 2017
Author: alc
Date: Sun Sep 24 16:50:10 2017
New Revision: 323973
URL: https://svnweb.freebsd.org/changeset/base/323973
Log:
Optimize vm_page_try_to_free(). Specifically, the call to pmap_remove_all()
can be avoided when the page's containing object has a reference count of
zero. (If the object has a reference count of zero, then none of its pages
can possibly be mapped.)
Address nearby style issues in vm_page_try_to_free(), and change its
return type to "bool".
Reviewed by: kib, markj
MFC after: 1 week
Modified:
head/sys/vm/vm_page.c
head/sys/vm/vm_page.h
Modified: head/sys/vm/vm_page.c
==============================================================================
--- head/sys/vm/vm_page.c Sun Sep 24 14:36:01 2017 (r323972)
+++ head/sys/vm/vm_page.c Sun Sep 24 16:50:10 2017 (r323973)
@@ -3081,23 +3081,25 @@ vm_page_unswappable(vm_page_t m)
* vm_page_try_to_free()
*
* Attempt to free the page. If we cannot free it, we do nothing.
- * 1 is returned on success, 0 on failure.
+ * true is returned on success, false on failure.
*/
-int
+bool
vm_page_try_to_free(vm_page_t m)
{
- vm_page_lock_assert(m, MA_OWNED);
+ vm_page_assert_locked(m);
if (m->object != NULL)
VM_OBJECT_ASSERT_WLOCKED(m->object);
- if (m->dirty || m->hold_count || m->wire_count ||
+ if (m->dirty != 0 || m->hold_count != 0 || m->wire_count != 0 ||
(m->oflags & VPO_UNMANAGED) != 0 || vm_page_busied(m))
- return (0);
- pmap_remove_all(m);
- if (m->dirty)
- return (0);
+ return (false);
+ if (m->object != NULL && m->object->ref_count != 0) {
+ pmap_remove_all(m);
+ if (m->dirty != 0)
+ return (false);
+ }
vm_page_free(m);
- return (1);
+ return (true);
}
/*
Modified: head/sys/vm/vm_page.h
==============================================================================
--- head/sys/vm/vm_page.h Sun Sep 24 14:36:01 2017 (r323972)
+++ head/sys/vm/vm_page.h Sun Sep 24 16:50:10 2017 (r323973)
@@ -477,7 +477,6 @@ void vm_page_change_lock(vm_page_t m, struct mtx **mtx
vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int);
int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
vm_page_t *ma, int count);
-int vm_page_try_to_free (vm_page_t);
void vm_page_deactivate (vm_page_t);
void vm_page_deactivate_noreuse(vm_page_t);
void vm_page_dequeue(vm_page_t m);
@@ -513,6 +512,7 @@ void vm_page_set_valid_range(vm_page_t m, int base, in
int vm_page_sleep_if_busy(vm_page_t m, const char *msg);
vm_offset_t vm_page_startup(vm_offset_t vaddr);
void vm_page_sunbusy(vm_page_t m);
+bool vm_page_try_to_free(vm_page_t m);
int vm_page_trysbusy(vm_page_t m);
void vm_page_unhold_pages(vm_page_t *ma, int count);
void vm_page_unswappable(vm_page_t m);
More information about the svn-src-head
mailing list