MPSAFE work - fix acquisition of vm_token
authorAlex Hornung <ahornung@gmail.com>
Fri, 18 Jun 2010 16:24:30 +0000 (17:24 +0100)
committerAlex Hornung <ahornung@gmail.com>
Fri, 18 Jun 2010 16:26:41 +0000 (17:26 +0100)
* vm_page_lookup needs to be called with the vm_token held, but
  vm_page_alloc wasn't acquiring it early enough.

sys/vm/vm_page.c

index cadbcba..953ef3e 100644 (file)
@@ -719,6 +719,9 @@ vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int page_req)
 {
        vm_page_t m = NULL;
 
+       crit_enter();
+       lwkt_gettoken(&vm_token);
+       
        KKASSERT(object != NULL);
        KASSERT(!vm_page_lookup(object, pindex),
                ("vm_page_alloc: page already allocated"));
@@ -733,8 +736,6 @@ vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int page_req)
        if (curthread->td_flags & TDF_SYSTHREAD)
                page_req |= VM_ALLOC_SYSTEM;
 
-       crit_enter();
-       lwkt_gettoken(&vm_token);
 loop:
        if (vmstats.v_free_count > vmstats.v_free_reserved ||
            ((page_req & VM_ALLOC_INTERRUPT) && vmstats.v_free_count > 0) ||