From b8c50480253bb89806d4f4b7a1b5104c0403801b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 8 Oct 2007 18:01:38 +0000 Subject: [PATCH] In the rare case that vm_page_cache() actually frees the given page, it must first ensure that the page is no longer mapped. This is trivially accomplished by calling pmap_remove_all() a little earlier in vm_page_cache(). While I'm in the neighborbood, make a related panic message a little more useful. Approved by: re (kensmith) Reported by: Peter Holm and Konstantin Belousov Reviewed by: Konstantin Belousov --- sys/vm/vm_page.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 10fe984e3986..e34b0669f205 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1506,6 +1506,9 @@ vm_page_cache(vm_page_t m) m->hold_count || m->wire_count) { panic("vm_page_cache: attempting to cache busy page"); } + pmap_remove_all(m); + if (m->dirty != 0) + panic("vm_page_cache: page %p is dirty", m); if (m->valid == 0 || object->type == OBJT_DEFAULT) { /* * Hypothesis: A cache-elgible page belonging to a @@ -1518,16 +1521,6 @@ vm_page_cache(vm_page_t m) ("vm_page_cache: page %p is already cached", m)); cnt.v_tcached++; - /* - * Remove all pmaps and indicate that the page is not - * writeable or mapped. - */ - pmap_remove_all(m); - if (m->dirty != 0) { - panic("vm_page_cache: caching a dirty page, pindex: %ld", - (long)m->pindex); - } - /* * Remove the page from the paging queues. */