vm_page.c (e532a99901e26d3961f8f5c0e4969fce86f09456) | vm_page.c (0fd977b3fa32d54b61554416363faae8a7bfaa2b) |
---|---|
1/*- 2 * SPDX-License-Identifier: (BSD-3-Clause AND MIT-CMU) 3 * 4 * Copyright (c) 1991 Regents of the University of California. 5 * All rights reserved. 6 * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 1444 unchanged lines hidden (view full) --- 1453 if (pmap_page_is_write_mapped(m)) 1454 vm_object_set_writeable_dirty(object); 1455} 1456 1457/* 1458 * vm_page_remove: 1459 * 1460 * Removes the specified page from its containing object, but does not | 1/*- 2 * SPDX-License-Identifier: (BSD-3-Clause AND MIT-CMU) 3 * 4 * Copyright (c) 1991 Regents of the University of California. 5 * All rights reserved. 6 * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 1444 unchanged lines hidden (view full) --- 1453 if (pmap_page_is_write_mapped(m)) 1454 vm_object_set_writeable_dirty(object); 1455} 1456 1457/* 1458 * vm_page_remove: 1459 * 1460 * Removes the specified page from its containing object, but does not |
1461 * invalidate any backing storage. | 1461 * invalidate any backing storage. Return true if the page may be safely 1462 * freed and false otherwise. |
1462 * 1463 * The object must be locked. The page must be locked if it is managed. 1464 */ | 1463 * 1464 * The object must be locked. The page must be locked if it is managed. 1465 */ |
1465void | 1466bool |
1466vm_page_remove(vm_page_t m) 1467{ 1468 vm_object_t object; 1469 vm_page_t mrem; 1470 | 1467vm_page_remove(vm_page_t m) 1468{ 1469 vm_object_t object; 1470 vm_page_t mrem; 1471 |
1472 object = m->object; 1473 |
|
1471 if ((m->oflags & VPO_UNMANAGED) == 0) 1472 vm_page_assert_locked(m); | 1474 if ((m->oflags & VPO_UNMANAGED) == 0) 1475 vm_page_assert_locked(m); |
1473 if ((object = m->object) == NULL) 1474 return; | |
1475 VM_OBJECT_ASSERT_WLOCKED(object); 1476 if (vm_page_xbusied(m)) 1477 vm_page_xunbusy_maybelocked(m); 1478 mrem = vm_radix_remove(&object->rtree, m->pindex); 1479 KASSERT(mrem == m, ("removed page %p, expected page %p", mrem, m)); 1480 1481 /* 1482 * Now remove from the object's list of backed pages. --- 7 unchanged lines hidden (view full) --- 1490 1491 /* 1492 * The vnode may now be recycled. 1493 */ 1494 if (object->resident_page_count == 0 && object->type == OBJT_VNODE) 1495 vdrop(object->handle); 1496 1497 m->object = NULL; | 1476 VM_OBJECT_ASSERT_WLOCKED(object); 1477 if (vm_page_xbusied(m)) 1478 vm_page_xunbusy_maybelocked(m); 1479 mrem = vm_radix_remove(&object->rtree, m->pindex); 1480 KASSERT(mrem == m, ("removed page %p, expected page %p", mrem, m)); 1481 1482 /* 1483 * Now remove from the object's list of backed pages. --- 7 unchanged lines hidden (view full) --- 1491 1492 /* 1493 * The vnode may now be recycled. 1494 */ 1495 if (object->resident_page_count == 0 && object->type == OBJT_VNODE) 1496 vdrop(object->handle); 1497 1498 m->object = NULL; |
1499 return (!vm_page_wired(m)); |
|
1498} 1499 1500/* 1501 * vm_page_lookup: 1502 * 1503 * Returns the page associated with the object/offset 1504 * pair specified; if none is found, NULL is returned. 1505 * --- 154 unchanged lines hidden (view full) --- 1660 } 1661 1662 /* 1663 * The operation cannot fail anymore. The removal must happen before 1664 * the listq iterator is tainted. 1665 */ 1666 m->pindex = opidx; 1667 vm_page_lock(m); | 1500} 1501 1502/* 1503 * vm_page_lookup: 1504 * 1505 * Returns the page associated with the object/offset 1506 * pair specified; if none is found, NULL is returned. 1507 * --- 154 unchanged lines hidden (view full) --- 1662 } 1663 1664 /* 1665 * The operation cannot fail anymore. The removal must happen before 1666 * the listq iterator is tainted. 1667 */ 1668 m->pindex = opidx; 1669 vm_page_lock(m); |
1668 vm_page_remove(m); | 1670 (void)vm_page_remove(m); |
1669 1670 /* Return back to the new pindex to complete vm_page_insert(). */ 1671 m->pindex = new_pindex; 1672 m->object = new_object; 1673 vm_page_unlock(m); 1674 vm_page_insert_radixdone(m, new_object, mpred); 1675 vm_page_dirty(m); 1676 return (0); --- 1754 unchanged lines hidden (view full) --- 3431 } else 3432 KASSERT(m->queue == PQ_NONE, 3433 ("vm_page_free_prep: unmanaged page %p is queued", m)); 3434 VM_CNT_INC(v_tfree); 3435 3436 if (vm_page_sbusied(m)) 3437 panic("vm_page_free_prep: freeing busy page %p", m); 3438 | 1671 1672 /* Return back to the new pindex to complete vm_page_insert(). */ 1673 m->pindex = new_pindex; 1674 m->object = new_object; 1675 vm_page_unlock(m); 1676 vm_page_insert_radixdone(m, new_object, mpred); 1677 vm_page_dirty(m); 1678 return (0); --- 1754 unchanged lines hidden (view full) --- 3433 } else 3434 KASSERT(m->queue == PQ_NONE, 3435 ("vm_page_free_prep: unmanaged page %p is queued", m)); 3436 VM_CNT_INC(v_tfree); 3437 3438 if (vm_page_sbusied(m)) 3439 panic("vm_page_free_prep: freeing busy page %p", m); 3440 |
3439 vm_page_remove(m); | 3441 if (m->object != NULL) 3442 (void)vm_page_remove(m); |
3440 3441 /* 3442 * If fictitious remove object association and 3443 * return. 3444 */ 3445 if ((m->flags & PG_FICTITIOUS) != 0) { 3446 KASSERT(m->wire_count == 1, 3447 ("fictitious page %p is not wired", m)); --- 1081 unchanged lines hidden --- | 3443 3444 /* 3445 * If fictitious remove object association and 3446 * return. 3447 */ 3448 if ((m->flags & PG_FICTITIOUS) != 0) { 3449 KASSERT(m->wire_count == 1, 3450 ("fictitious page %p is not wired", m)); --- 1081 unchanged lines hidden --- |