The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=fffc1c594a7382ae4da963dfa9901e549cfa5e9d

commit fffc1c594a7382ae4da963dfa9901e549cfa5e9d
Author:     Mark Johnston <[email protected]>
AuthorDate: 2022-07-16 15:28:55 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2022-07-17 11:09:48 +0000

    vm_object: Release object swap charge in the swap pager destructor
    
    With the removal of OBJT_DEFAULT, we can simply handle this in
    swap_pager_dealloc().  No functional change intended.
    
    Suggested by:   alc
    Reviewed by:    alc, kib
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D35787
---
 sys/vm/swap_pager.c | 14 ++++++++++++++
 sys/vm/vm_object.c  | 18 ------------------
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 931659f1891b..c20360975c4b 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -787,6 +787,20 @@ swap_pager_dealloc(vm_object_t object)
        swp_pager_meta_free_all(object);
        object->handle = NULL;
        object->type = OBJT_DEAD;
+
+       /*
+        * Release the allocation charge.
+        */
+       if (object->cred != NULL) {
+               swap_release_by_cred(object->charge, object->cred);
+               object->charge = 0;
+               crfree(object->cred);
+               object->cred = NULL;
+       }
+
+       /*
+        * Hide the object from swap_pager_swapoff().
+        */
        vm_object_clear_flag(object, OBJ_SWAP);
 }
 
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 57904454eff7..bb29568ab5e4 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -702,27 +702,9 @@ vm_object_deallocate(vm_object_t object)
        }
 }
 
-/*
- *     vm_object_destroy removes the object from the global object list
- *      and frees the space for the object.
- */
 void
 vm_object_destroy(vm_object_t object)
 {
-
-       /*
-        * Release the allocation charge.
-        */
-       if (object->cred != NULL) {
-               swap_release_by_cred(object->charge, object->cred);
-               object->charge = 0;
-               crfree(object->cred);
-               object->cred = NULL;
-       }
-
-       /*
-        * Free the space for the object.
-        */
        uma_zfree(obj_zone, object);
 }
 

Reply via email to