From bd93d4966c5d78cb4ee2ab84d32890ea1ca77d53 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 25 May 2024 17:51:54 -0400 Subject: kernel: vm: Make vmobj ref start at zero Signed-off-by: Ian Moffett --- sys/vm/vm_map.c | 4 ++-- sys/vm/vm_obj.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/vm') 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; -- cgit v1.2.3