* Use SYSREF for vmspace structures. This replaces the vmspace structure's
authorMatthew Dillon <dillon@dragonflybsd.org>
Sun, 29 Apr 2007 18:25:41 +0000 (18:25 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sun, 29 Apr 2007 18:25:41 +0000 (18:25 +0000)
commite31613239c64d0e42f19a17cd3d1081c8cd02679
tree903a4b51eac4fb730e708c80b7348283011e0f87
parent73ca6e3cf8a676d6a7f8778a060aa37000cf5dc6
* Use SYSREF for vmspace structures.  This replaces the vmspace structure's
  roll-your-own refcnt implementation and replaces its zalloc backing store.
  Numerous procedures have been added to handle termination and DTOR
  operations and to properly interlock with vm_exitingcnt, all centered
  around the vmspace_sysref_class declaration.

* Replace pmap_activate() and pmap_deactivate() with add pmap_replacevm().
  This replaces numerous instances where roll-your-own deactivate/activate
  sequences were being used, creating small windows of opportunity where
  an update to the kernel pmap would not be visible to running code.

* Properly deactivate pmaps and add assertions to the fact in the teardown
  code.  Cases had to be fixed in cpu_exit_switch(), the exec code, the
  AIO code, and a few other places.

* Add pmap_puninit() which is called as part of the DTOR sequence for
  vmspaces, allowing the kmem mapping and VM object to be recovered.
  We could not do this with the previous zalloc() implementation.

* Properly initialize the per-cpu sysid allocator (globaldata->gd_sysid_alloc).

Make the following adjustments to the LWP exiting code.

* P_WEXIT interlocks the master exiting thread, eliminating races which can
  occur when it is signaling the 'other' threads.

* LWP_WEXIT interlocks individual exiting threads, eliminating races which
  can occur there and streamlining some of the tests.

* Don't bother queueing the last LWP to the reaper.  Instead, just leave it
  in the p_lwps list (but still decrement nthreads), and add code to
  kern_wait() to reap the last thread.  This improves exit/wait performance
  for unthreaded applications.

* Fix a VMSPACE teardown race in the LWP code.  It turns out that it was
  still possible for the VMSPACE for an exiting LWP to be ripped out from
  under it by the reaper (due to a conditional that was really supposed to
  be a loop), or by kern_wait() (due to not waiting for all the LWPs to
  enter an exiting state).  The fix is to have the LWPs PHOLD() the process
  and then PRELE() it when they are reaped.

This is a little mixed up because the addition of SYSREF revealed a number
of other semi-related bugs in the pmap and LWP code which also had to be
fixed.
22 files changed:
sys/kern/imgact_resident.c
sys/kern/init_main.c
sys/kern/kern_exec.c
sys/kern/kern_exit.c
sys/kern/kern_fork.c
sys/kern/kern_sig.c
sys/kern/vfs_aio.c
sys/platform/pc32/i386/pmap.c
sys/platform/pc32/i386/swtch.s
sys/platform/pc32/i386/trap.c
sys/platform/vkernel/i386/swtch.s
sys/platform/vkernel/i386/trap.c
sys/platform/vkernel/platform/pmap.c
sys/sys/proc.h
sys/vfs/procfs/procfs_mem.c
sys/vm/pmap.h
sys/vm/vm_extern.h
sys/vm/vm_glue.c
sys/vm/vm_map.c
sys/vm/vm_map.h
sys/vm/vm_mmap.c
sys/vm/vm_vmspace.c