vm_object.c (296373) | vm_object.c (307929) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 49 unchanged lines hidden (view full) --- 58 * rights to redistribute these changes. 59 */ 60 61/* 62 * Virtual memory object module. 63 */ 64 65#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 49 unchanged lines hidden (view full) --- 58 * rights to redistribute these changes. 59 */ 60 61/* 62 * Virtual memory object module. 63 */ 64 65#include <sys/cdefs.h> |
66__FBSDID("$FreeBSD: releng/10.3/sys/vm/vm_object.c 292261 2015-12-15 12:58:33Z kib $"); | 66__FBSDID("$FreeBSD: releng/10.3/sys/vm/vm_object.c 307929 2016-10-25 16:45:55Z glebius $"); |
67 68#include "opt_vm.h" 69 70#include <sys/param.h> 71#include <sys/systm.h> 72#include <sys/lock.h> 73#include <sys/mman.h> 74#include <sys/mount.h> --- 657 unchanged lines hidden (view full) --- 732 /* 733 * Clean pages and flush buffers. 734 */ 735 vm_object_page_clean(object, 0, 0, OBJPC_SYNC); 736 VM_OBJECT_WUNLOCK(object); 737 738 vinvalbuf(vp, V_SAVE, 0, 0); 739 | 67 68#include "opt_vm.h" 69 70#include <sys/param.h> 71#include <sys/systm.h> 72#include <sys/lock.h> 73#include <sys/mman.h> 74#include <sys/mount.h> --- 657 unchanged lines hidden (view full) --- 732 /* 733 * Clean pages and flush buffers. 734 */ 735 vm_object_page_clean(object, 0, 0, OBJPC_SYNC); 736 VM_OBJECT_WUNLOCK(object); 737 738 vinvalbuf(vp, V_SAVE, 0, 0); 739 |
740 BO_LOCK(&vp->v_bufobj); 741 vp->v_bufobj.bo_flag |= BO_DEAD; 742 BO_UNLOCK(&vp->v_bufobj); 743 |
|
740 VM_OBJECT_WLOCK(object); 741 } 742 743 KASSERT(object->ref_count == 0, 744 ("vm_object_terminate: object with references, ref_count=%d", 745 object->ref_count)); 746 747 /* --- 969 unchanged lines hidden (view full) --- 1717 * the parent bypass the object if the parent happens to shadow 1718 * all the resident pages in the entire backing object. 1719 * 1720 * This is ignoring pager-backed pages such as swap pages. 1721 * vm_object_backing_scan fails the shadowing test in this 1722 * case. 1723 */ 1724 if (backing_object->ref_count == 1) { | 744 VM_OBJECT_WLOCK(object); 745 } 746 747 KASSERT(object->ref_count == 0, 748 ("vm_object_terminate: object with references, ref_count=%d", 749 object->ref_count)); 750 751 /* --- 969 unchanged lines hidden (view full) --- 1721 * the parent bypass the object if the parent happens to shadow 1722 * all the resident pages in the entire backing object. 1723 * 1724 * This is ignoring pager-backed pages such as swap pages. 1725 * vm_object_backing_scan fails the shadowing test in this 1726 * case. 1727 */ 1728 if (backing_object->ref_count == 1) { |
1729 vm_object_pip_add(object, 1); 1730 vm_object_pip_add(backing_object, 1); 1731 |
|
1725 /* 1726 * If there is exactly one reference to the backing 1727 * object, we can collapse it into the parent. 1728 */ 1729 vm_object_backing_scan(object, OBSC_COLLAPSE_WAIT); 1730 1731#if VM_NRESERVLEVEL > 0 1732 /* --- 55 unchanged lines hidden (view full) --- 1788 * 1789 * Since the backing object has no pages, no pager left, 1790 * and no object references within it, all that is 1791 * necessary is to dispose of it. 1792 */ 1793 KASSERT(backing_object->ref_count == 1, ( 1794"backing_object %p was somehow re-referenced during collapse!", 1795 backing_object)); | 1732 /* 1733 * If there is exactly one reference to the backing 1734 * object, we can collapse it into the parent. 1735 */ 1736 vm_object_backing_scan(object, OBSC_COLLAPSE_WAIT); 1737 1738#if VM_NRESERVLEVEL > 0 1739 /* --- 55 unchanged lines hidden (view full) --- 1795 * 1796 * Since the backing object has no pages, no pager left, 1797 * and no object references within it, all that is 1798 * necessary is to dispose of it. 1799 */ 1800 KASSERT(backing_object->ref_count == 1, ( 1801"backing_object %p was somehow re-referenced during collapse!", 1802 backing_object)); |
1803 vm_object_pip_wakeup(backing_object); |
|
1796 backing_object->type = OBJT_DEAD; 1797 backing_object->ref_count = 0; 1798 VM_OBJECT_WUNLOCK(backing_object); 1799 vm_object_destroy(backing_object); 1800 | 1804 backing_object->type = OBJT_DEAD; 1805 backing_object->ref_count = 0; 1806 VM_OBJECT_WUNLOCK(backing_object); 1807 vm_object_destroy(backing_object); 1808 |
1809 vm_object_pip_wakeup(object); |
|
1801 object_collapses++; 1802 } else { 1803 vm_object_t new_backing_object; 1804 1805 /* 1806 * If we do not entirely shadow the backing object, 1807 * there is nothing we can do so we give up. 1808 */ --- 316 unchanged lines hidden (view full) --- 2125 * swap reservation during enabling of the write 2126 * access, so reserve swap now. Failed reservation 2127 * cause allocation of the separate object for the map 2128 * entry, and swap reservation for this entry is 2129 * managed in appropriate time. 2130 */ 2131 if (!reserved && !swap_reserve_by_cred(ptoa(next_size), 2132 prev_object->cred)) { | 1810 object_collapses++; 1811 } else { 1812 vm_object_t new_backing_object; 1813 1814 /* 1815 * If we do not entirely shadow the backing object, 1816 * there is nothing we can do so we give up. 1817 */ --- 316 unchanged lines hidden (view full) --- 2134 * swap reservation during enabling of the write 2135 * access, so reserve swap now. Failed reservation 2136 * cause allocation of the separate object for the map 2137 * entry, and swap reservation for this entry is 2138 * managed in appropriate time. 2139 */ 2140 if (!reserved && !swap_reserve_by_cred(ptoa(next_size), 2141 prev_object->cred)) { |
2142 VM_OBJECT_WUNLOCK(prev_object); |
|
2133 return (FALSE); 2134 } 2135 prev_object->charge += ptoa(next_size); 2136 } 2137 2138 /* 2139 * Remove any pages that may still be in the object from a previous 2140 * deallocation. --- 501 unchanged lines hidden --- | 2143 return (FALSE); 2144 } 2145 prev_object->charge += ptoa(next_size); 2146 } 2147 2148 /* 2149 * Remove any pages that may still be in the object from a previous 2150 * deallocation. --- 501 unchanged lines hidden --- |