kernel - Fix a SMP race in the 64-bit pmap code
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 1 Oct 2013 23:53:38 +0000 (16:53 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 2 Oct 2013 00:01:25 +0000 (17:01 -0700)
commit5e78aef9c66d402e1a066898964ad1bdd0ea8fa4
treef73ba308e7fde020c76c76287ffac43a920cced5
parentd7bfb2cbc2b575acb989d4aad0d2477b2f2fe693
kernel - Fix a SMP race in the 64-bit pmap code

* Some of the pmap code was assuming that pv_entry's would remain stable
  under circumstance where they might not actually remain stable.

  Specifically, when the vm_page spinlock is held while issuing a
  pv_hold_try() call on the pv, the pv is not necessarily stable
  and its pmap and pindex must be double-checked after a successful
  lock is acquired.  This case occurs in two places in the code.

* Do this check in all cases (when the pmap spinlock OR the vm_page spin
  lock is used to access a pv_entry), just to be sure that we have covered
  all the bases.

* This SMP race is virtually impossible to reproduce on 8-thread boxes
  but appears to be easy to reproduce on monster (48-way opteron).

* As of this commit it is not 100% clear if the patch fixes the assertion
  seen, but it probably fixes some things.

  panic: bad *ptep 000000078592b425 sva 00007ffffffff000 pte_pv NULL

Reported-by: ftigeot
sys/platform/pc64/x86_64/pmap.c