From fb6235893f78d9b8d43501a05e7f6b56ace14005 Mon Sep 17 00:00:00 2001 From: alc Date: Sun, 20 Apr 2003 21:56:40 +0000 Subject: - Update the vm_object locking in vm_map_insert(). --- sys/vm/vm_map.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'sys/vm/vm_map.c') diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 0450ee5..fdce55c 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -811,17 +811,22 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, if (cow & MAP_DISABLE_COREDUMP) protoeflags |= MAP_ENTRY_NOCOREDUMP; - if (object) { + if (object != NULL) { /* - * When object is non-NULL, it could be shared with another - * process. We have to set or clear OBJ_ONEMAPPING - * appropriately. + * OBJ_ONEMAPPING must be cleared unless this mapping + * is trivially proven to be the only mapping for any + * of the object's pages. (Object granularity + * reference counting is insufficient to recognize + * aliases with precision.) */ - vm_object_lock(object); - if ((object->ref_count > 1) || (object->shadow_count != 0)) { + if (object != kmem_object) + mtx_lock(&Giant); + VM_OBJECT_LOCK(object); + if (object->ref_count > 1 || object->shadow_count != 0) vm_object_clear_flag(object, OBJ_ONEMAPPING); - } - vm_object_unlock(object); + VM_OBJECT_UNLOCK(object); + if (object != kmem_object) + mtx_unlock(&Giant); } else if ((prev_entry != &map->header) && (prev_entry->eflags == protoeflags) && -- cgit v1.1