MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_object_terminate_pages

Function vm_object_terminate_pages

freebsd/vm/vm_object.c:879–917  ·  view source on GitHub ↗

* vm_object_terminate_pages removes any remaining pageable pages * from the object and resets the object to an empty state. */

Source from the content-addressed store, hash-verified

877 * from the object and resets the object to an empty state.
878 */
879static void
880vm_object_terminate_pages(vm_object_t object)
881{
882 vm_page_t p, p_next;
883
884 VM_OBJECT_ASSERT_WLOCKED(object);
885
886 /*
887 * Free any remaining pageable pages. This also removes them from the
888 * paging queues. However, don't free wired pages, just remove them
889 * from the object. Rather than incrementally removing each page from
890 * the object, the page and object are reset to any empty state.
891 */
892 TAILQ_FOREACH_SAFE(p, &object->memq, listq, p_next) {
893 vm_page_assert_unbusied(p);
894 KASSERT(p->object == object &&
895 (p->ref_count & VPRC_OBJREF) != 0,
896 ("vm_object_terminate_pages: page %p is inconsistent", p));
897
898 p->object = NULL;
899 if (vm_page_drop(p, VPRC_OBJREF) == VPRC_OBJREF) {
900 VM_CNT_INC(v_pfree);
901 vm_page_free(p);
902 }
903 }
904
905 /*
906 * If the object contained any pages, then reset it to an empty state.
907 * None of the object's fields, including "resident_page_count", were
908 * modified by the preceding loop.
909 */
910 if (object->resident_page_count != 0) {
911 vm_radix_reclaim_allnodes(&object->rtree);
912 TAILQ_INIT(&object->memq);
913 object->resident_page_count = 0;
914 if (object->type == OBJT_VNODE)
915 vdrop(object->handle);
916 }
917}
918
919/*
920 * vm_object_terminate actually destroys the specified object, freeing

Callers 1

vm_object_terminateFunction · 0.85

Calls 4

vm_page_dropFunction · 0.85
vm_page_freeFunction · 0.85
vdropFunction · 0.85

Tested by

no test coverage detected