]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/vm/memory_object.c
xnu-344.2.tar.gz
[apple/xnu.git] / osfmk / vm / memory_object.c
index 90de302291f790596ce38ed55e5cb4238ad8a85e..b65cc99480d5e6c60a0794e350fbabfccfececae 100644 (file)
@@ -188,8 +188,19 @@ memory_object_lock_page(
         *      does not have any data.
         */
 
-       if (m->absent || m->error || m->restart)
-               return(MEMORY_OBJECT_LOCK_RESULT_DONE);
+       if (m->absent || m->error || m->restart) {
+               if(m->error && should_flush) {
+                       /* dump the page, pager wants us to */
+                       /* clean it up and there is no      */
+                       /* relevant data to return */
+                       if(m->wire_count == 0) {
+                               VM_PAGE_FREE(m);
+                               return(MEMORY_OBJECT_LOCK_RESULT_DONE);
+                       }
+               } else {
+                       return(MEMORY_OBJECT_LOCK_RESULT_DONE);
+               }
+       }
 
        assert(!m->fictitious);
 
@@ -765,10 +776,7 @@ BYPASS_COW_COPYIN:
                                continue;
                        }
 
-                       PAGE_ASSERT_WAIT(m, THREAD_UNINT);
-                       vm_object_unlock(object);
-                       thread_block((void (*)(void))0);
-                       vm_object_lock(object);
+                       PAGE_SLEEP(object, m, THREAD_UNINT);
                        continue;
 
                    case MEMORY_OBJECT_LOCK_RESULT_MUST_CLEAN:
@@ -801,9 +809,7 @@ BYPASS_COW_COPYIN:
                        m->busy = FALSE;
                        holding_page = VM_PAGE_NULL;
                        if(m->cleaning) {
-                               PAGE_ASSERT_WAIT(m, THREAD_UNINT);
-                               vm_object_unlock(object);
-                               thread_block((void (*)(void))0);
+                               PAGE_SLEEP(object, m, THREAD_UNINT);
                                continue;
                        }
                        if(!pending_pageout) {
@@ -1451,9 +1457,12 @@ memory_manager_default_reference(
        mutex_lock(&memory_manager_default_lock);
        current_manager = memory_manager_default;
        while (current_manager == MEMORY_OBJECT_DEFAULT_NULL) {
-               thread_sleep_mutex((event_t) &memory_manager_default,
-                       &memory_manager_default_lock, THREAD_UNINT);
-               mutex_lock(&memory_manager_default_lock);
+               wait_result_t res;
+
+               res = thread_sleep_mutex((event_t) &memory_manager_default,
+                                        &memory_manager_default_lock,
+                                        THREAD_UNINT);
+               assert(res == THREAD_AWAKENED);
                current_manager = memory_manager_default;
        }
        memory_object_default_reference(current_manager);
@@ -1549,7 +1558,15 @@ memory_object_deactivate_pages(
                                        }
                                        VM_PAGE_QUEUES_REMOVE(m);
 
-                                       queue_enter_first(&vm_page_queue_inactive, m, vm_page_t, pageq);
+                                       if(m->zero_fill) {
+                                               queue_enter_first(
+                                                       &vm_page_queue_zf, 
+                                                       m, vm_page_t, pageq);
+                                       } else {
+                                               queue_enter_first(
+                                                       &vm_page_queue_inactive, 
+                                                       m, vm_page_t, pageq);
+                                       }
 
                                        m->inactive = TRUE;
                                        if (!m->fictitious)  
@@ -1634,10 +1651,7 @@ memory_object_page_op(
                           (ops & UPL_POP_BUSY)) || (ops & UPL_POP_DUMP))) {
                        /* someone else is playing with the page, we will */
                        /* have to wait */
-                       PAGE_ASSERT_WAIT(dst_page, THREAD_UNINT);
-                       vm_object_unlock(object);
-                       thread_block((void(*)(void))0);
-                       vm_object_lock(object);
+                       PAGE_SLEEP(object, dst_page, THREAD_UNINT);
                        continue;
                }