kernel -- vm_page_dontneed: Fix interaction with vm_page_madvise and pagedaemon
authorVenkatesh Srinivas <me@endeavour.zapto.org>
Sat, 24 Sep 2011 13:41:13 +0000 (06:41 -0700)
committerVenkatesh Srinivas <me@endeavour.zapto.org>
Sat, 24 Sep 2011 13:41:13 +0000 (06:41 -0700)
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.

sys/vm/vm_page.c

index 91527c6..fe28554 100644 (file)
@@ -1529,6 +1529,15 @@ vm_page_dontneed(vm_page_t m)
                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);