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

Function vm_object_terminate

freebsd/vm/vm_object.c:926–970  ·  view source on GitHub ↗

* vm_object_terminate actually destroys the specified object, freeing * up all previously used resources. * * The object must be locked. * This routine may block. */

Source from the content-addressed store, hash-verified

924 * This routine may block.
925 */
926void
927vm_object_terminate(vm_object_t object)
928{
929
930 VM_OBJECT_ASSERT_WLOCKED(object);
931 KASSERT((object->flags & OBJ_DEAD) != 0,
932 ("terminating non-dead obj %p", object));
933 KASSERT((object->flags & OBJ_COLLAPSING) == 0,
934 ("terminating collapsing obj %p", object));
935 KASSERT(object->backing_object == NULL,
936 ("terminating shadow obj %p", object));
937
938 /*
939 * Wait for the pageout daemon and other current users to be
940 * done with the object. Note that new paging_in_progress
941 * users can come after this wait, but they must check
942 * OBJ_DEAD flag set (without unlocking the object), and avoid
943 * the object being terminated.
944 */
945 vm_object_pip_wait(object, "objtrm");
946
947 KASSERT(object->ref_count == 0,
948 ("vm_object_terminate: object with references, ref_count=%d",
949 object->ref_count));
950
951 if ((object->flags & OBJ_PG_DTOR) == 0)
952 vm_object_terminate_pages(object);
953
954#if VM_NRESERVLEVEL > 0
955 if (__predict_false(!LIST_EMPTY(&object->rvq)))
956 vm_reserv_break_all(object);
957#endif
958
959 KASSERT(object->cred == NULL || object->type == OBJT_DEFAULT ||
960 object->type == OBJT_SWAP,
961 ("%s: non-swap obj %p has cred", __func__, object));
962
963 /*
964 * Let the pager know object is dead.
965 */
966 vm_pager_deallocate(object);
967 VM_OBJECT_WUNLOCK(object);
968
969 vm_object_destroy(object);
970}
971
972/*
973 * Make the page read-only so that we can clear the object flags. However, if

Callers 3

vm_object_deallocateFunction · 0.85
vm_object_collapseFunction · 0.85
vnode_destroy_vobjectFunction · 0.85

Calls 5

vm_object_pip_waitFunction · 0.85
vm_reserv_break_allFunction · 0.85
vm_pager_deallocateFunction · 0.85
vm_object_destroyFunction · 0.85

Tested by

no test coverage detected