Deleted Added
full compact
vm_fault.c (315971) vm_fault.c (316073)
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 *

--- 58 unchanged lines hidden (view full) ---

67 * rights to redistribute these changes.
68 */
69
70/*
71 * Page fault handling module.
72 */
73
74#include <sys/cdefs.h>
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 *

--- 58 unchanged lines hidden (view full) ---

67 * rights to redistribute these changes.
68 */
69
70/*
71 * Page fault handling module.
72 */
73
74#include <sys/cdefs.h>
75__FBSDID("$FreeBSD: stable/11/sys/vm/vm_fault.c 315971 2017-03-26 00:59:15Z kib $");
75__FBSDID("$FreeBSD: stable/11/sys/vm/vm_fault.c 316073 2017-03-28 06:07:59Z kib $");
76
77#include "opt_ktrace.h"
78#include "opt_vm.h"
79
80#include <sys/param.h>
81#include <sys/systm.h>
82#include <sys/kernel.h>
83#include <sys/lock.h>

--- 263 unchanged lines hidden (view full) ---

347
348 MPASS(fs->object == fs->first_object);
349 VM_OBJECT_ASSERT_WLOCKED(fs->first_object);
350 MPASS(fs->first_object->paging_in_progress > 0);
351 MPASS(fs->first_object->backing_object == NULL);
352 MPASS(fs->lookup_still_valid);
353
354 pager_first = OFF_TO_IDX(fs->entry->offset);
76
77#include "opt_ktrace.h"
78#include "opt_vm.h"
79
80#include <sys/param.h>
81#include <sys/systm.h>
82#include <sys/kernel.h>
83#include <sys/lock.h>

--- 263 unchanged lines hidden (view full) ---

347
348 MPASS(fs->object == fs->first_object);
349 VM_OBJECT_ASSERT_WLOCKED(fs->first_object);
350 MPASS(fs->first_object->paging_in_progress > 0);
351 MPASS(fs->first_object->backing_object == NULL);
352 MPASS(fs->lookup_still_valid);
353
354 pager_first = OFF_TO_IDX(fs->entry->offset);
355 pager_last = OFF_TO_IDX(fs->entry->offset + fs->entry->end -
356 fs->entry->start) - 1;
355 pager_last = pager_first + atop(fs->entry->end - fs->entry->start) - 1;
357 unlock_map(fs);
358 unlock_vp(fs);
359
360 /*
361 * Call the pager (driver) populate() method.
362 *
363 * There is no guarantee that the method will be called again
364 * if the current fault is for read, and a future fault is

--- 34 unchanged lines hidden (view full) ---

399 * The map is unchanged after our last unlock. Process the fault.
400 *
401 * The range [pager_first, pager_last] that is given to the
402 * pager is only a hint. The pager may populate any range
403 * within the object that includes the requested page index.
404 * In case the pager expanded the range, clip it to fit into
405 * the map entry.
406 */
356 unlock_map(fs);
357 unlock_vp(fs);
358
359 /*
360 * Call the pager (driver) populate() method.
361 *
362 * There is no guarantee that the method will be called again
363 * if the current fault is for read, and a future fault is

--- 34 unchanged lines hidden (view full) ---

398 * The map is unchanged after our last unlock. Process the fault.
399 *
400 * The range [pager_first, pager_last] that is given to the
401 * pager is only a hint. The pager may populate any range
402 * within the object that includes the requested page index.
403 * In case the pager expanded the range, clip it to fit into
404 * the map entry.
405 */
407 map_first = MAX(OFF_TO_IDX(fs->entry->offset), pager_first);
408 if (map_first > pager_first)
406 map_first = OFF_TO_IDX(fs->entry->offset);
407 if (map_first > pager_first) {
409 vm_fault_populate_cleanup(fs->first_object, pager_first,
410 map_first - 1);
408 vm_fault_populate_cleanup(fs->first_object, pager_first,
409 map_first - 1);
411 map_last = MIN(OFF_TO_IDX(fs->entry->end - fs->entry->start +
412 fs->entry->offset) - 1, pager_last);
413 if (map_last < pager_last)
410 pager_first = map_first;
411 }
412 map_last = map_first + atop(fs->entry->end - fs->entry->start) - 1;
413 if (map_last < pager_last) {
414 vm_fault_populate_cleanup(fs->first_object, map_last + 1,
415 pager_last);
414 vm_fault_populate_cleanup(fs->first_object, map_last + 1,
415 pager_last);
416
417 for (pidx = map_first, m = vm_page_lookup(fs->first_object, pidx);
418 pidx <= map_last; pidx++, m = vm_page_next(m)) {
416 pager_last = map_last;
417 }
418 for (pidx = pager_first, m = vm_page_lookup(fs->first_object, pidx);
419 pidx <= pager_last; pidx++, m = vm_page_next(m)) {
419 vm_fault_populate_check_page(m);
420 vm_fault_dirty(fs->entry, m, prot, fault_type, fault_flags,
421 true);
422 VM_OBJECT_WUNLOCK(fs->first_object);
423 pmap_enter(fs->map->pmap, fs->entry->start + IDX_TO_OFF(pidx) -
424 fs->entry->offset, m, prot, fault_type | (wired ?
425 PMAP_ENTER_WIRED : 0), 0);
426 VM_OBJECT_WLOCK(fs->first_object);

--- 1116 unchanged lines hidden (view full) ---

1543 dst_object = src_object;
1544 vm_object_reference(dst_object);
1545 } else {
1546 /*
1547 * Create the top-level object for the destination entry. (Doesn't
1548 * actually shadow anything - we copy the pages directly.)
1549 */
1550 dst_object = vm_object_allocate(OBJT_DEFAULT,
420 vm_fault_populate_check_page(m);
421 vm_fault_dirty(fs->entry, m, prot, fault_type, fault_flags,
422 true);
423 VM_OBJECT_WUNLOCK(fs->first_object);
424 pmap_enter(fs->map->pmap, fs->entry->start + IDX_TO_OFF(pidx) -
425 fs->entry->offset, m, prot, fault_type | (wired ?
426 PMAP_ENTER_WIRED : 0), 0);
427 VM_OBJECT_WLOCK(fs->first_object);

--- 1116 unchanged lines hidden (view full) ---

1544 dst_object = src_object;
1545 vm_object_reference(dst_object);
1546 } else {
1547 /*
1548 * Create the top-level object for the destination entry. (Doesn't
1549 * actually shadow anything - we copy the pages directly.)
1550 */
1551 dst_object = vm_object_allocate(OBJT_DEFAULT,
1551 OFF_TO_IDX(dst_entry->end - dst_entry->start));
1552 atop(dst_entry->end - dst_entry->start));
1552#if VM_NRESERVLEVEL > 0
1553 dst_object->flags |= OBJ_COLORED;
1554 dst_object->pg_color = atop(dst_entry->start);
1555#endif
1556 }
1557
1558 VM_OBJECT_WLOCK(dst_object);
1559 KASSERT(upgrade || dst_entry->object.vm_object == NULL,

--- 163 unchanged lines hidden ---
1553#if VM_NRESERVLEVEL > 0
1554 dst_object->flags |= OBJ_COLORED;
1555 dst_object->pg_color = atop(dst_entry->start);
1556#endif
1557 }
1558
1559 VM_OBJECT_WLOCK(dst_object);
1560 KASSERT(upgrade || dst_entry->object.vm_object == NULL,

--- 163 unchanged lines hidden ---