kernel - Refactor the vmspace locking code and several use cases
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 2 Dec 2011 00:54:19 +0000 (16:54 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 2 Dec 2011 00:54:19 +0000 (16:54 -0800)
commita2ee730d0cec9395df7e733b2ca627cccbb0633a
tree96289173c05bfc966ade8ab1e97fd27ae4e19322
parent72a0763ae1ed5a58943e5e6d00c12013aac65ee2
kernel - Refactor the vmspace locking code and several use cases

* Reorder the vnode ref/rele sequence in the exec path so p_textvp is
  left in a more valid state while being initialized.

* Removing the vm_exitingcnt test in exec_new_vmspace().  Release
  various resources unconditionally on the last exiting thread regardless
  of the state of exitingcnt.  This just moves some of the resource
  releases out of the wait*() system call path and back into the exit*()
  path.

* Implement a hold/drop mechanic for vmspaces and use them in procfs_rwmem(),
  vmspace_anonymous_count(), and vmspace_swap_count(), and various other
  places.

  This does a better job protecting the vmspace from deletion while various
  unrelated third parties might be trying to access it.

* Implement vmspace_free() for other code to call instead of them trying
  to call sysref_put() directly.  Interlock with a vmspace_hold() so
  final termination processing always keys off the vm_holdcount.

* Implement vm_object_allocate_hold() and use it in a few places in order
  to allow OBJT_SWAP objects to be allocated atomically, so other third
  parties (like the swapcache cleaning code) can't wiggle their way in
  and access a partially initialized object.

* Reorder the vmspace_terminate() code and introduce some flags to ensure
  that resources are terminated at the proper time and in the proper order.
13 files changed:
sys/kern/imgact_resident.c
sys/kern/kern_exec.c
sys/vfs/procfs/procfs_mem.c
sys/vm/device_pager.c
sys/vm/swap_pager.c
sys/vm/vm_extern.h
sys/vm/vm_glue.c
sys/vm/vm_map.c
sys/vm/vm_map.h
sys/vm/vm_object.c
sys/vm/vm_object.h
sys/vm/vm_vmspace.c
sys/vm/vm_zone.c