vm_page_dontneed didn't clear the PG_REFERENCED flag on pages it is
deactivating. The pagedaemon would see references on the page (via
PG_REFERENCED) and reactivate it, undoing the effect of vm_page_dontneed.
return;
}
+ /*
+ * If vm_page_dontneed() is inactivating a page, it must clear
+ * the referenced flag; otherwise the pagedaemon will see references
+ * on the page in the inactive queue and reactivate it. Until the
+ * page can move to the cache queue, madvise's job is not done.
+ */
+ vm_page_flag_clear(m, PG_REFERENCED);
+ pmap_clear_reference(m);
+
if (m->dirty == 0)
vm_page_test_dirty(m);