vm_fault.c (da8b3304fbb4ffd4caafc80ad6513aeb5c72cf28) | vm_fault.c (05f0fdd26aa1789c04ae89358880922a54d197c3) |
---|---|
1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1994 John S. Dyson 5 * All rights reserved. 6 * Copyright (c) 1994 David Greenman 7 * All rights reserved. 8 * --- 52 unchanged lines hidden (view full) --- 61 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 62 * School of Computer Science 63 * Carnegie Mellon University 64 * Pittsburgh PA 15213-3890 65 * 66 * any improvements or extensions that they make and grant Carnegie the 67 * rights to redistribute these changes. 68 * | 1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1994 John S. Dyson 5 * All rights reserved. 6 * Copyright (c) 1994 David Greenman 7 * All rights reserved. 8 * --- 52 unchanged lines hidden (view full) --- 61 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 62 * School of Computer Science 63 * Carnegie Mellon University 64 * Pittsburgh PA 15213-3890 65 * 66 * any improvements or extensions that they make and grant Carnegie the 67 * rights to redistribute these changes. 68 * |
69 * $Id: vm_fault.c,v 1.5 1994/10/05 09:48:42 davidg Exp $ | 69 * $Id: vm_fault.c,v 1.6 1994/10/09 00:18:22 davidg Exp $ |
70 */ 71 72/* 73 * Page fault handling module. 74 */ 75 76#include <sys/param.h> 77#include <sys/systm.h> 78#include <sys/proc.h> | 70 */ 71 72/* 73 * Page fault handling module. 74 */ 75 76#include <sys/param.h> 77#include <sys/systm.h> 78#include <sys/proc.h> |
79#include <sys/resource.h> 80#include <sys/signalvar.h> |
|
79#include <sys/resourcevar.h> 80 81#include <vm/vm.h> 82#include <vm/vm_page.h> 83#include <vm/vm_pageout.h> 84 | 81#include <sys/resourcevar.h> 82 83#include <vm/vm.h> 84#include <vm/vm_page.h> 85#include <vm/vm_pageout.h> 86 |
87int vm_fault_additional_pages __P((vm_object_t, vm_offset_t, vm_page_t, int, int, vm_page_t *, int *)); |
|
85 86#define VM_FAULT_READ_AHEAD 4 87#define VM_FAULT_READ_AHEAD_MIN 1 88#define VM_FAULT_READ_BEHIND 3 89#define VM_FAULT_READ (VM_FAULT_READ_AHEAD+VM_FAULT_READ_BEHIND+1) 90extern int swap_pager_full; 91extern int vm_pageout_proc_limit; 92 --- 33 unchanged lines hidden (view full) --- 126 int result; 127 boolean_t wired; 128 boolean_t su; 129 boolean_t lookup_still_valid; 130 boolean_t page_exists; 131 vm_page_t old_m; 132 vm_object_t next_object; 133 vm_page_t marray[VM_FAULT_READ]; | 88 89#define VM_FAULT_READ_AHEAD 4 90#define VM_FAULT_READ_AHEAD_MIN 1 91#define VM_FAULT_READ_BEHIND 3 92#define VM_FAULT_READ (VM_FAULT_READ_AHEAD+VM_FAULT_READ_BEHIND+1) 93extern int swap_pager_full; 94extern int vm_pageout_proc_limit; 95 --- 33 unchanged lines hidden (view full) --- 129 int result; 130 boolean_t wired; 131 boolean_t su; 132 boolean_t lookup_still_valid; 133 boolean_t page_exists; 134 vm_page_t old_m; 135 vm_object_t next_object; 136 vm_page_t marray[VM_FAULT_READ]; |
134 int reqpage; | |
135 int spl; 136 int hardfault=0; 137 138 cnt.v_faults++; /* needs lock XXX */ 139/* 140 * Recovery actions 141 */ 142#define FREE_PAGE(m) { \ --- 178 unchanged lines hidden (view full) --- 321 goto RetryFault; 322 } 323#endif 324 325 if (swap_pager_full && !object->shadow && (!object->pager || 326 (object->pager && object->pager->pg_type == PG_SWAP && 327 !vm_pager_has_page(object->pager, offset+object->paging_offset)))) { 328 if (vaddr < VM_MAXUSER_ADDRESS && curproc && curproc->p_pid >= 48) /* XXX */ { | 137 int spl; 138 int hardfault=0; 139 140 cnt.v_faults++; /* needs lock XXX */ 141/* 142 * Recovery actions 143 */ 144#define FREE_PAGE(m) { \ --- 178 unchanged lines hidden (view full) --- 323 goto RetryFault; 324 } 325#endif 326 327 if (swap_pager_full && !object->shadow && (!object->pager || 328 (object->pager && object->pager->pg_type == PG_SWAP && 329 !vm_pager_has_page(object->pager, offset+object->paging_offset)))) { 330 if (vaddr < VM_MAXUSER_ADDRESS && curproc && curproc->p_pid >= 48) /* XXX */ { |
329 printf("Process %d killed by vm_fault -- out of swap\n", curproc->p_pid); | 331 printf("Process %lu killed by vm_fault -- out of swap\n", (u_long)curproc->p_pid); |
330 psignal(curproc, SIGKILL); 331 curproc->p_estcpu = 0; 332 curproc->p_nice = PRIO_MIN; 333 resetpriority(curproc); 334 } 335 } 336 337 /* --- 27 unchanged lines hidden (view full) --- 365 * reside in the same object as the page for this fault. If 366 * they do, then they are faulted in also into the 367 * object. The array "marray" returned contains an array of 368 * vm_page_t structs where one of them is the vm_page_t passed to 369 * the routine. The reqpage return value is the index into the 370 * marray for the vm_page_t passed to the routine. 371 */ 372 cnt.v_pageins++; | 332 psignal(curproc, SIGKILL); 333 curproc->p_estcpu = 0; 334 curproc->p_nice = PRIO_MIN; 335 resetpriority(curproc); 336 } 337 } 338 339 /* --- 27 unchanged lines hidden (view full) --- 367 * reside in the same object as the page for this fault. If 368 * they do, then they are faulted in also into the 369 * object. The array "marray" returned contains an array of 370 * vm_page_t structs where one of them is the vm_page_t passed to 371 * the routine. The reqpage return value is the index into the 372 * marray for the vm_page_t passed to the routine. 373 */ 374 cnt.v_pageins++; |
373 faultcount = vm_fault_additional_pages(first_object, first_offset, 374 m, VM_FAULT_READ_BEHIND, VM_FAULT_READ_AHEAD, marray, &reqpage); | 375 faultcount = vm_fault_additional_pages( 376 first_object, first_offset, 377 m, VM_FAULT_READ_BEHIND, VM_FAULT_READ_AHEAD, 378 marray, &reqpage); |
375 376 /* 377 * Call the pager to retrieve the data, if any, 378 * after releasing the lock on the map. 379 */ 380 UNLOCK_MAP; 381 382 rv = faultcount ? --- 254 unchanged lines hidden (view full) --- 637 copy_object->ref_count++; 638 639 /* 640 * Does the page exist in the copy? 641 */ 642 copy_offset = first_offset 643 - copy_object->shadow_offset; 644 copy_m = vm_page_lookup(copy_object, copy_offset); | 379 380 /* 381 * Call the pager to retrieve the data, if any, 382 * after releasing the lock on the map. 383 */ 384 UNLOCK_MAP; 385 386 rv = faultcount ? --- 254 unchanged lines hidden (view full) --- 641 copy_object->ref_count++; 642 643 /* 644 * Does the page exist in the copy? 645 */ 646 copy_offset = first_offset 647 - copy_object->shadow_offset; 648 copy_m = vm_page_lookup(copy_object, copy_offset); |
645 if (page_exists = (copy_m != NULL)) { | 649 page_exists = (copy_m != NULL); 650 if (page_exists) { |
646 if (copy_m->flags & (PG_BUSY|PG_VMIO)) { 647 /* 648 * If the page is being brought 649 * in, wait for it and then retry. 650 */ 651 PAGE_ASSERT_WAIT(copy_m, !change_wiring); 652 RELEASE_PAGE(m); 653 copy_object->ref_count--; --- 457 unchanged lines hidden (view full) --- 1111vm_fault_page_lookup(object, offset, rtobject, rtoffset, rtm) 1112 vm_object_t object; 1113 vm_offset_t offset; 1114 vm_object_t *rtobject; 1115 vm_offset_t *rtoffset; 1116 vm_page_t *rtm; 1117{ 1118 vm_page_t m; | 651 if (copy_m->flags & (PG_BUSY|PG_VMIO)) { 652 /* 653 * If the page is being brought 654 * in, wait for it and then retry. 655 */ 656 PAGE_ASSERT_WAIT(copy_m, !change_wiring); 657 RELEASE_PAGE(m); 658 copy_object->ref_count--; --- 457 unchanged lines hidden (view full) --- 1116vm_fault_page_lookup(object, offset, rtobject, rtoffset, rtm) 1117 vm_object_t object; 1118 vm_offset_t offset; 1119 vm_object_t *rtobject; 1120 vm_offset_t *rtoffset; 1121 vm_page_t *rtm; 1122{ 1123 vm_page_t m; |
1119 vm_object_t first_object = object; | |
1120 1121 *rtm = 0; 1122 *rtobject = 0; 1123 *rtoffset = 0; 1124 1125 1126 while (!(m=vm_page_lookup(object, offset))) { 1127 if (object->pager) { --- 36 unchanged lines hidden (view full) --- 1164 vm_offset_t first_offset; 1165 vm_page_t m; 1166 int rbehind; 1167 int raheada; 1168 vm_page_t *marray; 1169 int *reqpage; 1170{ 1171 int i; | 1124 1125 *rtm = 0; 1126 *rtobject = 0; 1127 *rtoffset = 0; 1128 1129 1130 while (!(m=vm_page_lookup(object, offset))) { 1131 if (object->pager) { --- 36 unchanged lines hidden (view full) --- 1168 vm_offset_t first_offset; 1169 vm_page_t m; 1170 int rbehind; 1171 int raheada; 1172 vm_page_t *marray; 1173 int *reqpage; 1174{ 1175 int i; |
1172 vm_page_t tmpm; | |
1173 vm_object_t object; 1174 vm_offset_t offset, startoffset, endoffset, toffset, size; 1175 vm_object_t rtobject; 1176 vm_page_t rtm; 1177 vm_offset_t rtoffset; 1178 vm_offset_t offsetdiff; 1179 int rahead; 1180 int treqpage; --- 130 unchanged lines hidden --- | 1176 vm_object_t object; 1177 vm_offset_t offset, startoffset, endoffset, toffset, size; 1178 vm_object_t rtobject; 1179 vm_page_t rtm; 1180 vm_offset_t rtoffset; 1181 vm_offset_t offsetdiff; 1182 int rahead; 1183 int treqpage; --- 130 unchanged lines hidden --- |