BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / vm / vm_pageout.c
index 4e6301f..5270ae3 100644 (file)
@@ -1,29 +1,76 @@
 /* 
 /* 
- * Copyright (c) 1985, Avadis Tevanian, Jr., Michael Wayne Young
- * Copyright (c) 1987 Carnegie-Mellon University
  * Copyright (c) 1991 Regents of the University of California.
  * All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * The Mach Operating System project at Carnegie-Mellon University.
  *
  * Copyright (c) 1991 Regents of the University of California.
  * All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * The Mach Operating System project at Carnegie-Mellon University.
  *
- * The CMU software License Agreement specifies the terms and conditions
- * for use and redistribution.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)vm_pageout.c        7.1 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)vm_pageout.c        7.4 (Berkeley) 5/7/91
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Authors: Avadis Tevanian, Jr., Michael Wayne Young
+ * 
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
  */
 
 /*
  *     The proverbial page-out daemon.
  */
 
  */
 
 /*
  *     The proverbial page-out daemon.
  */
 
-#include "types.h"
-#include "../vm/vm_page.h"
-#include "../vm/pmap.h"
-#include "../vm/vm_object.h"
-#include "../vm/vm_pageout.h"
-#include "../vm/vm_statistics.h"
-#include "../vm/vm_param.h"
+#include "param.h"
+
+#include "vm.h"
+#include "vm_page.h"
+#include "vm_pageout.h"
 
 int    vm_pages_needed;                /* Event on which pageout daemon sleeps */
 int    vm_pageout_free_min = 0;        /* Stop pageout to wait for pagers at this free level */
 
 int    vm_pages_needed;                /* Event on which pageout daemon sleeps */
 int    vm_pageout_free_min = 0;        /* Stop pageout to wait for pagers at this free level */
@@ -106,7 +153,8 @@ vm_pageout_scan()
                                        m = next;
                                        continue;
                                }
                                        m = next;
                                        continue;
                                }
-                               pmap_remove_all(VM_PAGE_TO_PHYS(m));
+                               pmap_page_protect(VM_PAGE_TO_PHYS(m),
+                                                 VM_PROT_NONE);
                                vm_page_free(m);        /* will dequeue */
                                pages_freed++;
                                vm_object_unlock(object);
                                vm_page_free(m);        /* will dequeue */
                                pages_freed++;
                                vm_object_unlock(object);
@@ -153,7 +201,8 @@ vm_pageout_scan()
                                        continue;
                                }
 
                                        continue;
                                }
 
-                               pmap_remove_all(VM_PAGE_TO_PHYS(m));
+                               pmap_page_protect(VM_PAGE_TO_PHYS(m),
+                                                 VM_PROT_NONE);
                                m->busy = TRUE;
                                vm_stat.pageouts++;
 
                                m->busy = TRUE;
                                vm_stat.pageouts++;
 
@@ -184,12 +233,12 @@ vm_pageout_scan()
                                 *      later.
                                 */
 
                                 *      later.
                                 */
 
-                               if ((pager = object->pager) == vm_pager_null) {
+                               if ((pager = object->pager) == NULL) {
                                        pager = vm_pager_allocate(PG_DFLT,
                                                                  (caddr_t)0,
                                                                  object->size,
                                                                  VM_PROT_ALL);
                                        pager = vm_pager_allocate(PG_DFLT,
                                                                  (caddr_t)0,
                                                                  object->size,
                                                                  VM_PROT_ALL);
-                                       if (pager != vm_pager_null) {
+                                       if (pager != NULL) {
                                                vm_object_setpager(object,
                                                        pager, 0, FALSE);
                                        }
                                                vm_object_setpager(object,
                                                        pager, 0, FALSE);
                                        }
@@ -229,16 +278,19 @@ vm_pageout_scan()
                                }
 
                                pmap_clear_reference(VM_PAGE_TO_PHYS(m));
                                }
 
                                pmap_clear_reference(VM_PAGE_TO_PHYS(m));
-                               m->busy = FALSE;
-                               PAGE_WAKEUP(m);
 
                                /*
 
                                /*
-                                * If the operation is still going, leave the
-                                * paging in progress indicator set so that we
-                                * don't attempt an object collapse.
+                                * If the operation is still going, leave
+                                * the page busy to block all other accesses.
+                                * Also, leave the paging in progress
+                                * indicator set so that we don't attempt an
+                                * object collapse.
                                 */
                                 */
-                               if (pageout_status != VM_PAGER_PEND)
+                               if (pageout_status != VM_PAGER_PEND) {
+                                       m->busy = FALSE;
+                                       PAGE_WAKEUP(m);
                                        object->paging_in_progress--;
                                        object->paging_in_progress--;
+                               }
                                thread_wakeup((int) object);
                                vm_object_unlock(object);
                                m = next;
                                thread_wakeup((int) object);
                                vm_object_unlock(object);
                                m = next;