Avoid acquiring the object lock if color is already set. It can not be

unset until the object is recycled so this check is stable.  Now that we
can acquire the ref without a lock it is not necessary to group these
operations and we can avoid it entirely in many cases.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D22565
This commit is contained in:
Jeff Roberson 2019-11-29 19:49:20 +00:00
parent 26c4e9831b
commit f2410510db

View File

@ -1325,12 +1325,14 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize,
} else {
KASSERT(obj->type == OBJT_DEFAULT || obj->type == OBJT_SWAP,
("wrong object type"));
VM_OBJECT_WLOCK(obj);
vm_object_reference_locked(obj);
vm_object_reference(obj);
#if VM_NRESERVLEVEL > 0
vm_object_color(obj, 0);
if ((obj->flags & OBJ_COLORED) == 0) {
VM_OBJECT_WLOCK(obj);
vm_object_color(obj, 0);
VM_OBJECT_WUNLOCK(obj);
}
#endif
VM_OBJECT_WUNLOCK(obj);
}
*objp = obj;
*flagsp = flags;