kernel - Fix exec optimization race
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 5 Nov 2014 19:04:11 +0000 (11:04 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 6 Nov 2014 18:51:24 +0000 (10:51 -0800)
* Fix an improper vm_page_unhold() in exec_map_page() which
  under heavy memory loads can cause a later assertion
  on m->hold_count == 0.

* Triggered every few days by bulk builds on pkgbox64.

sys/kern/kern_exec.c

index ffb7246..6bcbfe4 100644 (file)
@@ -668,12 +668,13 @@ exec_map_page(struct image_params *imgp, vm_pindex_t pageno,
                if ((m->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL) {
                        vm_page_hold(m);
                        vm_page_sleep_busy(m, FALSE, "execpg");
-                       if ((m->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL) {
+                       if ((m->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL &&
+                           m->object == object && m->pindex == pageno) {
                                vm_object_drop(object);
                                goto done;
                        }
+                       vm_page_unhold(m);
                }
-               vm_page_unhold(m);
        }
        vm_object_drop(object);