summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2001-03-04 20:25:23 +0000
committeralfred <alfred@FreeBSD.org>2001-03-04 20:25:23 +0000
commit1c4e3d51b79802e243de0825320182551e3cb530 (patch)
treec1830987e4fa42eb3ad7ca8bfda39e8929385d07
parent907000cc31414f82b778e5dd0d75f38fe7b1eafd (diff)
downloadFreeBSD-src-1c4e3d51b79802e243de0825320182551e3cb530.zip
FreeBSD-src-1c4e3d51b79802e243de0825320182551e3cb530.tar.gz
Simplify vm_object_deallocate(), by decrementing the refcount first.
This allows some of the conditionals to be combined.
-rw-r--r--sys/vm/vm_object.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 39191b1..fdfb5d8 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -301,24 +301,23 @@ vm_object_deallocate(object)
return;
}
- if (object->ref_count == 0) {
- panic("vm_object_deallocate: object deallocated too many times: %d", object->type);
- } else if (object->ref_count > 2) {
- object->ref_count--;
- return;
- }
+ KASSERT(object->ref_count != 0,
+ ("vm_object_deallocate: object deallocated too many times: %d", object->type));
/*
- * Here on ref_count of one or two, which are special cases for
- * objects.
+ * If the reference count goes to 0 we start calling
+ * vm_object_terminate() on the object chain.
+ * A ref count of 1 may be a special case depending on the
+ * shadow count being 0 or 1.
*/
- if ((object->ref_count == 2) && (object->shadow_count == 0)) {
- vm_object_set_flag(object, OBJ_ONEMAPPING);
- object->ref_count--;
+ object->ref_count--;
+ if (object->ref_count > 1) {
return;
- } else if ((object->ref_count == 2) && (object->shadow_count == 1)) {
- object->ref_count--;
- if ((object->handle == NULL) &&
+ } else if (object->ref_count == 1) {
+ if (object->shadow_count == 0) {
+ vm_object_set_flag(object, OBJ_ONEMAPPING);
+ } else if ((object->shadow_count == 1) &&
+ (object->handle == NULL) &&
(object->type == OBJT_DEFAULT ||
object->type == OBJT_SWAP)) {
vm_object_t robject;
@@ -356,10 +355,6 @@ vm_object_deallocate(object)
return;
- } else {
- object->ref_count--;
- if (object->ref_count != 0)
- return;
}
doterm:
OpenPOWER on IntegriCloud