vm_object.c (2828dafcf3e7b225b70cbb380eb8c7dae452493e) | vm_object.c (7667839a7ec4354de9984d411c45cbacf9fe8e3b) |
---|---|
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 --- 164 unchanged lines hidden (view full) --- 173 ("object %p has resident pages in its memq", object)); 174 KASSERT(vm_radix_is_empty(&object->rtree), 175 ("object %p has resident pages in its trie", object)); 176#if VM_NRESERVLEVEL > 0 177 KASSERT(LIST_EMPTY(&object->rvq), 178 ("object %p has reservations", 179 object)); 180#endif | 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 --- 164 unchanged lines hidden (view full) --- 173 ("object %p has resident pages in its memq", object)); 174 KASSERT(vm_radix_is_empty(&object->rtree), 175 ("object %p has resident pages in its trie", object)); 176#if VM_NRESERVLEVEL > 0 177 KASSERT(LIST_EMPTY(&object->rvq), 178 ("object %p has reservations", 179 object)); 180#endif |
181 KASSERT(vm_object_cache_is_empty(object), 182 ("object %p has cached pages", 183 object)); | |
184 KASSERT(object->paging_in_progress == 0, 185 ("object %p paging_in_progress = %d", 186 object, object->paging_in_progress)); 187 KASSERT(object->resident_page_count == 0, 188 ("object %p resident_page_count = %d", 189 object, object->resident_page_count)); 190 KASSERT(object->shadow_count == 0, 191 ("object %p shadow_count = %d", --- 15 unchanged lines hidden (view full) --- 207 /* These are true for any object that has been freed */ 208 object->type = OBJT_DEAD; 209 object->ref_count = 0; 210 object->rtree.rt_root = 0; 211 object->rtree.rt_flags = 0; 212 object->paging_in_progress = 0; 213 object->resident_page_count = 0; 214 object->shadow_count = 0; | 181 KASSERT(object->paging_in_progress == 0, 182 ("object %p paging_in_progress = %d", 183 object, object->paging_in_progress)); 184 KASSERT(object->resident_page_count == 0, 185 ("object %p resident_page_count = %d", 186 object, object->resident_page_count)); 187 KASSERT(object->shadow_count == 0, 188 ("object %p shadow_count = %d", --- 15 unchanged lines hidden (view full) --- 204 /* These are true for any object that has been freed */ 205 object->type = OBJT_DEAD; 206 object->ref_count = 0; 207 object->rtree.rt_root = 0; 208 object->rtree.rt_flags = 0; 209 object->paging_in_progress = 0; 210 object->resident_page_count = 0; 211 object->shadow_count = 0; |
215 object->cache.rt_root = 0; 216 object->cache.rt_flags = 0; | |
217 218 mtx_lock(&vm_object_list_mtx); 219 TAILQ_INSERT_TAIL(&vm_object_list, object, object_list); 220 mtx_unlock(&vm_object_list_mtx); 221 return (0); 222} 223 224static void --- 562 unchanged lines hidden (view full) --- 787 if (object->type == OBJT_VNODE) 788 vdrop(object->handle); 789 } 790 791#if VM_NRESERVLEVEL > 0 792 if (__predict_false(!LIST_EMPTY(&object->rvq))) 793 vm_reserv_break_all(object); 794#endif | 212 213 mtx_lock(&vm_object_list_mtx); 214 TAILQ_INSERT_TAIL(&vm_object_list, object, object_list); 215 mtx_unlock(&vm_object_list_mtx); 216 return (0); 217} 218 219static void --- 562 unchanged lines hidden (view full) --- 782 if (object->type == OBJT_VNODE) 783 vdrop(object->handle); 784 } 785 786#if VM_NRESERVLEVEL > 0 787 if (__predict_false(!LIST_EMPTY(&object->rvq))) 788 vm_reserv_break_all(object); 789#endif |
795 if (__predict_false(!vm_object_cache_is_empty(object))) 796 vm_page_cache_free(object, 0, 0); | |
797 798 KASSERT(object->cred == NULL || object->type == OBJT_DEFAULT || 799 object->type == OBJT_SWAP, 800 ("%s: non-swap obj %p has cred", __func__, object)); 801 802 /* 803 * Let the pager know object is dead. 804 */ --- 325 unchanged lines hidden (view full) --- 1130 if ((tobject->type != OBJT_DEFAULT && 1131 tobject->type != OBJT_SWAP) || 1132 (tobject->flags & OBJ_ONEMAPPING) == 0) { 1133 goto unlock_tobject; 1134 } 1135 } else if ((tobject->flags & OBJ_UNMANAGED) != 0) 1136 goto unlock_tobject; 1137 m = vm_page_lookup(tobject, tpindex); | 790 791 KASSERT(object->cred == NULL || object->type == OBJT_DEFAULT || 792 object->type == OBJT_SWAP, 793 ("%s: non-swap obj %p has cred", __func__, object)); 794 795 /* 796 * Let the pager know object is dead. 797 */ --- 325 unchanged lines hidden (view full) --- 1123 if ((tobject->type != OBJT_DEFAULT && 1124 tobject->type != OBJT_SWAP) || 1125 (tobject->flags & OBJ_ONEMAPPING) == 0) { 1126 goto unlock_tobject; 1127 } 1128 } else if ((tobject->flags & OBJ_UNMANAGED) != 0) 1129 goto unlock_tobject; 1130 m = vm_page_lookup(tobject, tpindex); |
1138 if (m == NULL && advise == MADV_WILLNEED) { 1139 /* 1140 * If the page is cached, reactivate it. 1141 */ 1142 m = vm_page_alloc(tobject, tpindex, VM_ALLOC_IFCACHED | 1143 VM_ALLOC_NOBUSY); 1144 } | |
1145 if (m == NULL) { 1146 /* 1147 * There may be swap even if there is no backing page 1148 */ 1149 if (advise == MADV_FREE && tobject->type == OBJT_SWAP) 1150 swap_pager_freespace(tobject, tpindex, 1); 1151 /* 1152 * next object --- 248 unchanged lines hidden (view full) --- 1401 if (orig_object->type == OBJT_SWAP) { 1402 /* 1403 * swap_pager_copy() can sleep, in which case the orig_object's 1404 * and new_object's locks are released and reacquired. 1405 */ 1406 swap_pager_copy(orig_object, new_object, offidxstart, 0); 1407 TAILQ_FOREACH(m, &new_object->memq, listq) 1408 vm_page_xunbusy(m); | 1131 if (m == NULL) { 1132 /* 1133 * There may be swap even if there is no backing page 1134 */ 1135 if (advise == MADV_FREE && tobject->type == OBJT_SWAP) 1136 swap_pager_freespace(tobject, tpindex, 1); 1137 /* 1138 * next object --- 248 unchanged lines hidden (view full) --- 1387 if (orig_object->type == OBJT_SWAP) { 1388 /* 1389 * swap_pager_copy() can sleep, in which case the orig_object's 1390 * and new_object's locks are released and reacquired. 1391 */ 1392 swap_pager_copy(orig_object, new_object, offidxstart, 0); 1393 TAILQ_FOREACH(m, &new_object->memq, listq) 1394 vm_page_xunbusy(m); |
1409 1410 /* 1411 * Transfer any cached pages from orig_object to new_object. 1412 * If swap_pager_copy() found swapped out pages within the 1413 * specified range of orig_object, then it changed 1414 * new_object's type to OBJT_SWAP when it transferred those 1415 * pages to new_object. Otherwise, new_object's type 1416 * should still be OBJT_DEFAULT and orig_object should not 1417 * contain any cached pages within the specified range. 1418 */ 1419 if (__predict_false(!vm_object_cache_is_empty(orig_object))) 1420 vm_page_cache_transfer(orig_object, offidxstart, 1421 new_object); | |
1422 } 1423 VM_OBJECT_WUNLOCK(orig_object); 1424 VM_OBJECT_WUNLOCK(new_object); 1425 entry->object.vm_object = new_object; 1426 entry->offset = 0LL; 1427 vm_object_deallocate(orig_object); 1428 VM_OBJECT_WLOCK(new_object); 1429} --- 319 unchanged lines hidden (view full) --- 1749 * Since swap_pager_copy() is being asked to 1750 * destroy the source, it will change the 1751 * backing_object's type to OBJT_DEFAULT. 1752 */ 1753 swap_pager_copy( 1754 backing_object, 1755 object, 1756 OFF_TO_IDX(object->backing_object_offset), TRUE); | 1395 } 1396 VM_OBJECT_WUNLOCK(orig_object); 1397 VM_OBJECT_WUNLOCK(new_object); 1398 entry->object.vm_object = new_object; 1399 entry->offset = 0LL; 1400 vm_object_deallocate(orig_object); 1401 VM_OBJECT_WLOCK(new_object); 1402} --- 319 unchanged lines hidden (view full) --- 1722 * Since swap_pager_copy() is being asked to 1723 * destroy the source, it will change the 1724 * backing_object's type to OBJT_DEFAULT. 1725 */ 1726 swap_pager_copy( 1727 backing_object, 1728 object, 1729 OFF_TO_IDX(object->backing_object_offset), TRUE); |
1757 1758 /* 1759 * Free any cached pages from backing_object. 1760 */ 1761 if (__predict_false( 1762 !vm_object_cache_is_empty(backing_object))) 1763 vm_page_cache_free(backing_object, 0, 0); | |
1764 } 1765 /* 1766 * Object now shadows whatever backing_object did. 1767 * Note that the reference to 1768 * backing_object->backing_object moves from within 1769 * backing_object to within object. 1770 */ 1771 LIST_REMOVE(object, shadow_list); --- 112 unchanged lines hidden (view full) --- 1884{ 1885 vm_page_t p, next; 1886 1887 VM_OBJECT_ASSERT_WLOCKED(object); 1888 KASSERT((object->flags & OBJ_UNMANAGED) == 0 || 1889 (options & (OBJPR_CLEANONLY | OBJPR_NOTMAPPED)) == OBJPR_NOTMAPPED, 1890 ("vm_object_page_remove: illegal options for object %p", object)); 1891 if (object->resident_page_count == 0) | 1730 } 1731 /* 1732 * Object now shadows whatever backing_object did. 1733 * Note that the reference to 1734 * backing_object->backing_object moves from within 1735 * backing_object to within object. 1736 */ 1737 LIST_REMOVE(object, shadow_list); --- 112 unchanged lines hidden (view full) --- 1850{ 1851 vm_page_t p, next; 1852 1853 VM_OBJECT_ASSERT_WLOCKED(object); 1854 KASSERT((object->flags & OBJ_UNMANAGED) == 0 || 1855 (options & (OBJPR_CLEANONLY | OBJPR_NOTMAPPED)) == OBJPR_NOTMAPPED, 1856 ("vm_object_page_remove: illegal options for object %p", object)); 1857 if (object->resident_page_count == 0) |
1892 goto skipmemq; | 1858 return; |
1893 vm_object_pip_add(object, 1); 1894again: 1895 p = vm_page_find_least(object, start); 1896 1897 /* 1898 * Here, the variable "p" is either (1) the page with the least pindex 1899 * greater than or equal to the parameter "start" or (2) NULL. 1900 */ --- 40 unchanged lines hidden (view full) --- 1941 } 1942 if ((options & OBJPR_NOTMAPPED) == 0) 1943 pmap_remove_all(p); 1944 vm_page_free(p); 1945next: 1946 vm_page_unlock(p); 1947 } 1948 vm_object_pip_wakeup(object); | 1859 vm_object_pip_add(object, 1); 1860again: 1861 p = vm_page_find_least(object, start); 1862 1863 /* 1864 * Here, the variable "p" is either (1) the page with the least pindex 1865 * greater than or equal to the parameter "start" or (2) NULL. 1866 */ --- 40 unchanged lines hidden (view full) --- 1907 } 1908 if ((options & OBJPR_NOTMAPPED) == 0) 1909 pmap_remove_all(p); 1910 vm_page_free(p); 1911next: 1912 vm_page_unlock(p); 1913 } 1914 vm_object_pip_wakeup(object); |
1949skipmemq: 1950 if (__predict_false(!vm_object_cache_is_empty(object))) 1951 vm_page_cache_free(object, start, end); | |
1952} 1953 1954/* 1955 * vm_object_page_noreuse: 1956 * 1957 * For the given object, attempt to move the specified pages to 1958 * the head of the inactive queue. This bypasses regular LRU 1959 * operation and allows the pages to be reused quickly under memory --- 680 unchanged lines hidden --- | 1915} 1916 1917/* 1918 * vm_object_page_noreuse: 1919 * 1920 * For the given object, attempt to move the specified pages to 1921 * the head of the inactive queue. This bypasses regular LRU 1922 * operation and allows the pages to be reused quickly under memory --- 680 unchanged lines hidden --- |