diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -4436,7 +4436,8 @@ VM_OBJECT_ASSERT_WLOCKED(m->object); vm_page_assert_xbusied(m); - if (advice == MADV_FREE) + switch (advice) { + case MADV_FREE: /* * Mark the page clean. This will allow the page to be freed * without first paging it out. MADV_FREE pages are often @@ -4444,15 +4445,19 @@ * would result in a page fault on a later access. */ vm_page_undirty(m); - else if (advice != MADV_DONTNEED) { - if (advice == MADV_WILLNEED) - vm_page_activate(m); + break; + case MADV_DONTNEED: + if (m->dirty == 0 && pmap_is_modified(m)) + vm_page_dirty(m); + break; + case MADV_WILLNEED: + vm_page_activate(m); + return; + default: + /* Do nothing. */ return; } - if (advice != MADV_FREE && m->dirty == 0 && pmap_is_modified(m)) - vm_page_dirty(m); - /* * Clear any references to the page. Otherwise, the page daemon will * immediately reactivate the page.