aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-25 17:51:54 -0400
committerIan Moffett <ian@osmora.org>2024-05-25 17:51:54 -0400
commitbd93d4966c5d78cb4ee2ab84d32890ea1ca77d53 (patch)
treebb8dc5e2a967679f288c3deed81a56af9a60f0c6 /sys
parent32f395140a653e5c7e3e114faeb7314e223f0eea (diff)
kernel: vm: Make vmobj ref start at zero
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/include/vm/obj.h2
-rw-r--r--sys/vm/vm_map.c4
-rw-r--r--sys/vm/vm_obj.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/sys/include/vm/obj.h b/sys/include/vm/obj.h
index e4258ac..6e24516 100644
--- a/sys/include/vm/obj.h
+++ b/sys/include/vm/obj.h
@@ -49,7 +49,7 @@ struct vm_object {
#define vm_object_ref(OBJPTR) (++(OBJPTR)->ref)
#define vm_object_unref(OBJPTR) do { \
- if ((OBJPTR)->ref > 1) { \
+ if ((OBJPTR)->ref > 0) { \
--(OBJPTR)->ref; \
} \
} while (0);
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index afe6760..2501e08 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -305,12 +305,12 @@ munmap(void *addr, size_t len)
spinlock_acquire(&obj->lock);
/*
* Drop our ref and try to cleanup. If the refcount
- * is > 1, something is still holding it and we can't
+ * is > 0, something is still holding it and we can't
* do much.
*/
vm_object_unref(obj);
vp = obj->vnode;
- if (vp != NULL && obj->ref == 1) {
+ if (vp != NULL && obj->ref == 0) {
vp->vmobj = NULL;
vm_obj_destroy(obj);
}
diff --git a/sys/vm/vm_obj.c b/sys/vm/vm_obj.c
index 8f34ff3..6dbe777 100644
--- a/sys/vm/vm_obj.c
+++ b/sys/vm/vm_obj.c
@@ -61,7 +61,7 @@ vm_obj_init(struct vm_object **res, struct vnode *vnode)
memset(obj, 0, sizeof(struct vm_object));
obj->vnode = vnode;
- obj->ref = 1;
+ obj->ref = 0;
vm_set_pgops(obj, vnode);
*res = obj;