kernel - Fix vkernel race in host
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 28 Jan 2017 18:30:53 +0000 (10:30 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 28 Jan 2017 18:30:53 +0000 (10:30 -0800)
commit98e80c6197a3c9407427208478cd1c813ff5f1ec
treea00c6162633cee648ecde4e19623ad54edc82e6d
parent8c6462e6588c8764bcf4e131e7127a0af96b5578
kernel - Fix vkernel race in host

* Obtaining a cache_ref before setting the DELETED flag deals with any
  drop race on cache_refs from another thread.

  This is actually quite elegant when done correctly.  The VKE_REF_DELETED
  on ve->refs determines when the ve has been destroyed, while
  ve->cache_refs determines when to kfree() the ve.  Acquiring an extra
  cache_ref before setting DELETED interlocks the two fields for last-drop
  purposes.
sys/vm/vm_vmspace.c