diff options
author | alc <alc@FreeBSD.org> | 2004-05-12 04:27:18 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2004-05-12 04:27:18 +0000 |
commit | 625c8dfb268731e7bf8cdfdc85229b25d4ba35b9 (patch) | |
tree | 1ad3a895c594bdb22f2dd660187f8af7c92e5909 /sys/vm | |
parent | 14bc83bc9c967d7557e40bd525990e9c923ff4e1 (diff) | |
download | FreeBSD-src-625c8dfb268731e7bf8cdfdc85229b25d4ba35b9.zip FreeBSD-src-625c8dfb268731e7bf8cdfdc85229b25d4ba35b9.tar.gz |
Restructure vm_page_select_cache() so that adding assertions is easy.
Some of the conditions that caused vm_page_select_cache() to deactivate a
page were wrong. For example, deactivating an unmanaged or wired page is a
nop. Thus, if vm_page_select_cache() had ever encountered an unmanaged or
wired page, it would have looped forever. Now, we assert that the page is
neither unmanaged nor wired.
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_page.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 014a0ef..24a7de9 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -708,17 +708,23 @@ vm_page_select_cache(int color) vm_page_t m; mtx_assert(&vm_page_queue_mtx, MA_OWNED); - while (TRUE) { - m = vm_pageq_find(PQ_CACHE, color, FALSE); - if (m && ((m->flags & (PG_BUSY|PG_UNMANAGED)) || m->busy || - m->hold_count || m->wire_count || - (!VM_OBJECT_TRYLOCK(m->object) && - !VM_OBJECT_LOCKED(m->object)))) { - vm_page_deactivate(m); - continue; + while ((m = vm_pageq_find(PQ_CACHE, color, FALSE)) != NULL) { + if ((m->flags & PG_BUSY) == 0 && m->busy == 0 && + m->hold_count == 0 && (VM_OBJECT_TRYLOCK(m->object) || + VM_OBJECT_LOCKED(m->object))) { + KASSERT(m->dirty == 0, + ("Found dirty cache page %p", m)); + KASSERT(!pmap_page_is_mapped(m), + ("Found mapped cache page %p", m)); + KASSERT((m->flags & PG_UNMANAGED) == 0, + ("Found unmanaged cache page %p", m)); + KASSERT(m->wire_count == 0, + ("Found wired cache page %p", m)); + break; } - return m; + vm_page_deactivate(m); } + return (m); } /* @@ -795,7 +801,6 @@ loop: pagedaemon_wakeup(); return (NULL); } - KASSERT(m->dirty == 0, ("Found dirty cache page %p", m)); m_object = m->object; VM_OBJECT_LOCK_ASSERT(m_object, MA_OWNED); vm_page_busy(m); |