1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-27 11:55:06 +00:00

Add a vm_page_wired() predicate.

Use it instead of accessing the wire_count field directly.  No
functional change intended.

Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D20485
This commit is contained in:
Mark Johnston 2019-06-02 01:00:17 +00:00
parent 03f92fe9e0
commit d842aa5114
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348502
7 changed files with 29 additions and 22 deletions

View File

@ -262,7 +262,7 @@ v2sizep(vm_offset_t va)
if (pa == 0)
panic("MemGuard detected double-free of %p", (void *)va);
p = PHYS_TO_VM_PAGE(pa);
KASSERT(p->wire_count != 0 && p->queue == PQ_NONE,
KASSERT(vm_page_wired(p) && p->queue == PQ_NONE,
("MEMGUARD: Expected wired page %p in vtomgfifo!", p));
return (&p->plinks.memguard.p);
}
@ -277,7 +277,7 @@ v2sizev(vm_offset_t va)
if (pa == 0)
panic("MemGuard detected double-free of %p", (void *)va);
p = PHYS_TO_VM_PAGE(pa);
KASSERT(p->wire_count != 0 && p->queue == PQ_NONE,
KASSERT(vm_page_wired(p) && p->queue == PQ_NONE,
("MEMGUARD: Expected wired page %p in vtomgfifo!", p));
return (&p->plinks.memguard.v);
}

View File

@ -1679,7 +1679,7 @@ swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex)
vm_page_dirty(m);
#ifdef INVARIANTS
vm_page_lock(m);
if (m->wire_count == 0 && m->queue == PQ_NONE)
if (!vm_page_wired(m) && m->queue == PQ_NONE)
panic("page %p is neither wired nor queued", m);
vm_page_unlock(m);
#endif

View File

@ -1004,7 +1004,7 @@ RetryFault:;
*/
if (rv == VM_PAGER_ERROR || rv == VM_PAGER_BAD) {
vm_page_lock(fs.m);
if (fs.m->wire_count == 0)
if (!vm_page_wired(fs.m))
vm_page_free(fs.m);
else
vm_page_xunbusy_maybelocked(fs.m);
@ -1027,7 +1027,7 @@ RetryFault:;
*/
if (fs.object != fs.first_object) {
vm_page_lock(fs.m);
if (fs.m->wire_count == 0)
if (!vm_page_wired(fs.m))
vm_page_free(fs.m);
else
vm_page_xunbusy_maybelocked(fs.m);
@ -1805,7 +1805,7 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map,
vm_page_wire(dst_m);
vm_page_unlock(dst_m);
} else {
KASSERT(dst_m->wire_count > 0,
KASSERT(vm_page_wired(dst_m),
("dst_m %p is not wired", dst_m));
}
} else {

View File

@ -720,7 +720,7 @@ vm_object_terminate_pages(vm_object_t object)
*/
vm_page_change_lock(p, &mtx);
p->object = NULL;
if (p->wire_count != 0)
if (vm_page_wired(p))
continue;
VM_CNT_INC(v_pfree);
vm_page_free(p);
@ -1595,7 +1595,7 @@ vm_object_collapse_scan(vm_object_t object, int op)
vm_page_lock(p);
KASSERT(!pmap_page_is_mapped(p),
("freeing mapped page %p", p));
if (p->wire_count == 0)
if (!vm_page_wired(p))
vm_page_free(p);
else
vm_page_remove(p);
@ -1639,7 +1639,7 @@ vm_object_collapse_scan(vm_object_t object, int op)
vm_page_lock(p);
KASSERT(!pmap_page_is_mapped(p),
("freeing mapped page %p", p));
if (p->wire_count == 0)
if (!vm_page_wired(p))
vm_page_free(p);
else
vm_page_remove(p);
@ -1944,7 +1944,7 @@ vm_object_page_remove(vm_object_t object, vm_pindex_t start, vm_pindex_t end,
VM_OBJECT_WLOCK(object);
goto again;
}
if (p->wire_count != 0) {
if (vm_page_wired(p)) {
if ((options & OBJPR_NOTMAPPED) == 0 &&
object->ref_count != 0)
pmap_remove_all(p);

View File

@ -2608,7 +2608,7 @@ vm_page_reclaim_run(int req_class, int domain, u_long npages, vm_page_t m_run,
error = ENOMEM;
goto unlock;
}
KASSERT(m_new->wire_count == 0,
KASSERT(!vm_page_wired(m_new),
("page %p is wired", m_new));
/*
@ -3434,7 +3434,7 @@ vm_page_activate(vm_page_t m)
vm_page_assert_locked(m);
if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
return;
if (vm_page_queue(m) == PQ_ACTIVE) {
if (m->act_count < ACT_INIT)
@ -3509,7 +3509,7 @@ vm_page_free_prep(vm_page_t m)
m->valid = 0;
vm_page_undirty(m);
if (m->wire_count != 0)
if (vm_page_wired(m) != 0)
panic("vm_page_free_prep: freeing wired page %p", m);
if (m->hold_count != 0) {
m->flags &= ~PG_ZERO;
@ -3610,7 +3610,7 @@ vm_page_wire(vm_page_t m)
m));
return;
}
if (m->wire_count == 0) {
if (!vm_page_wired(m)) {
KASSERT((m->oflags & VPO_UNMANAGED) == 0 ||
m->queue == PQ_NONE,
("vm_page_wire: unmanaged page %p is queued", m));
@ -3688,7 +3688,7 @@ vm_page_unwire_noq(vm_page_t m)
("vm_page_unwire: fictitious page %p's wire count isn't one", m));
return (false);
}
if (m->wire_count == 0)
if (!vm_page_wired(m))
panic("vm_page_unwire: page %p's wire count is zero", m);
m->wire_count--;
if (m->wire_count == 0) {
@ -3710,7 +3710,7 @@ vm_page_deactivate(vm_page_t m)
vm_page_assert_locked(m);
if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
return;
if (!vm_page_inactive(m)) {
@ -3734,7 +3734,7 @@ vm_page_deactivate_noreuse(vm_page_t m)
vm_page_assert_locked(m);
if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
return;
if (!vm_page_inactive(m)) {
@ -3756,7 +3756,7 @@ vm_page_launder(vm_page_t m)
{
vm_page_assert_locked(m);
if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
return;
if (vm_page_in_laundry(m))
@ -3777,7 +3777,7 @@ vm_page_unswappable(vm_page_t m)
{
vm_page_assert_locked(m);
KASSERT(m->wire_count == 0 && (m->oflags & VPO_UNMANAGED) == 0,
KASSERT(!vm_page_wired(m) && (m->oflags & VPO_UNMANAGED) == 0,
("page %p already unswappable", m));
vm_page_dequeue(m);

View File

@ -822,5 +822,12 @@ vm_page_held(vm_page_t m)
return (m->hold_count > 0 || m->wire_count > 0);
}
static inline bool
vm_page_wired(vm_page_t m)
{
return (m->wire_count > 0);
}
#endif /* _KERNEL */
#endif /* !_VM_PAGE_ */

View File

@ -754,7 +754,7 @@ vm_pageout_launder(struct vm_domain *vmd, int launder, bool in_shortfall)
*/
if (m->hold_count != 0)
continue;
if (m->wire_count != 0) {
if (vm_page_wired(m)) {
vm_page_dequeue_deferred(m);
continue;
}
@ -1203,7 +1203,7 @@ vm_pageout_scan_active(struct vm_domain *vmd, int page_shortage)
/*
* Wired pages are dequeued lazily.
*/
if (m->wire_count != 0) {
if (vm_page_wired(m)) {
vm_page_dequeue_deferred(m);
continue;
}
@ -1430,7 +1430,7 @@ vm_pageout_scan_inactive(struct vm_domain *vmd, int shortage,
addl_page_shortage++;
goto reinsert;
}
if (m->wire_count != 0) {
if (vm_page_wired(m)) {
vm_page_dequeue_deferred(m);
continue;
}