From 31da5e4d0cbd142b2ea4e6281890ee475f1f9711 Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Sat, 24 Sep 2011 06:41:13 -0700 Subject: [PATCH] kernel -- vm_page_dontneed: Fix interaction with vm_page_madvise and pagedaemon 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 | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 91527c6..fe28554 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -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); -- 1.7.7.2