summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_object.c
diff options
context:
space:
mode:
authordyson <dyson@FreeBSD.org>1996-05-23 00:45:58 +0000
committerdyson <dyson@FreeBSD.org>1996-05-23 00:45:58 +0000
commit509f02d4a3034d089f3b708293f367e91cdc784b (patch)
tree93cb5552524c0e6c7df6625358d83c0aaf76b71e /sys/vm/vm_object.c
parentc8d511854a4e1ec4a0e64833ef0f7e2f67d521d5 (diff)
downloadFreeBSD-src-509f02d4a3034d089f3b708293f367e91cdc784b.zip
FreeBSD-src-509f02d4a3034d089f3b708293f367e91cdc784b.tar.gz
Initial support for MADV_FREE, support for pages that we don't care
about the contents anymore. This gives us alot of the advantage of freeing individual pages through munmap, but with almost none of the overhead.
Diffstat (limited to 'sys/vm/vm_object.c')
-rw-r--r--sys/vm/vm_object.c68
1 files changed, 12 insertions, 56 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 83ee0cd..da2c62c 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -61,7 +61,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_object.c,v 1.71 1996/05/21 05:26:27 dyson Exp $
+ * $Id: vm_object.c,v 1.72 1996/05/21 17:13:31 dyson Exp $
*/
/*
@@ -709,7 +709,9 @@ vm_object_madvise(object, pindex, count, advise)
if (advise == MADV_WILLNEED) {
if (m->queue != PQ_ACTIVE)
vm_page_activate(m);
- } else if (advise == MADV_DONTNEED) {
+ } else if ((advise == MADV_DONTNEED) ||
+ ((advise == MADV_FREE) &&
+ ((object->type != OBJT_DEFAULT) && (object->type != OBJT_SWAP)))) {
/*
* If the upper level VM system doesn't think that
* the page is dirty, check the pmap layer.
@@ -732,65 +734,19 @@ vm_object_madvise(object, pindex, count, advise)
vm_page_protect(m, VM_PROT_NONE);
vm_page_deactivate(m);
}
+ } else if (advise == MADV_FREE) {
+ /*
+ * Force a demand-zero on next ref
+ */
+ if (object->type == OBJT_SWAP)
+ swap_pager_dmzspace(object, m->pindex, 1);
+ vm_page_protect(m, VM_PROT_NONE);
+ vm_page_free(m);
}
}
}
/*
- * vm_object_copy:
- *
- * Create a new object which is a copy of an existing
- * object, and mark all of the pages in the existing
- * object 'copy-on-write'. The new object has one reference.
- * Returns the new object.
- *
- * May defer the copy until later if the object is not backed
- * up by a non-default pager.
- *
- */
-void
-vm_object_copy(src_object, src_offset,
- dst_object, dst_offset, src_needs_copy)
- register vm_object_t src_object;
- vm_pindex_t src_offset;
- vm_object_t *dst_object;/* OUT */
- vm_pindex_t *dst_offset;/* OUT */
- boolean_t *src_needs_copy; /* OUT */
-{
- if (src_object == NULL) {
- /*
- * Nothing to copy
- */
- *dst_object = NULL;
- *dst_offset = 0;
- *src_needs_copy = FALSE;
- return;
- }
-
- /*
- * Try to collapse the object before copying it.
- */
- if (src_object->handle == NULL &&
- (src_object->type == OBJT_DEFAULT ||
- src_object->type == OBJT_SWAP))
- vm_object_collapse(src_object);
-
-
- /*
- * Make another reference to the object
- */
- src_object->ref_count++;
- *dst_object = src_object;
- *dst_offset = src_offset;
-
- /*
- * Must make a shadow when write is desired
- */
- *src_needs_copy = TRUE;
- return;
-}
-
-/*
* vm_object_shadow:
*
* Create a new object which is backed by the
OpenPOWER on IntegriCloud