From 1407f23d9b97600890c2fa7903a6077f6023d4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 3 Apr 2007 11:23:37 +0000 Subject: [PATCH] * The test for existing mappings in vm_remove_consumer() was a bit too aggressive; if the page is currently copied, the source page still has mappings. * vm_copy_on_write_area() did not set the cache type for the upper cache. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20530 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm.cpp | 1 + src/system/kernel/vm/vm_cache.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 967b39076b..8274d87ead 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -1586,6 +1586,7 @@ vm_copy_on_write_area(vm_area *area) // we need to hold the cache_ref lock when we want to switch its cache mutex_lock(&lowerCacheRef->lock); + upperCache->type = CACHE_TYPE_RAM; upperCache->temporary = 1; upperCache->scan_skip = lowerCache->scan_skip; upperCache->virtual_base = lowerCache->virtual_base; diff --git a/src/system/kernel/vm/vm_cache.c b/src/system/kernel/vm/vm_cache.c index eaf88bb877..e3a20f470b 100644 --- a/src/system/kernel/vm/vm_cache.c +++ b/src/system/kernel/vm/vm_cache.c @@ -528,16 +528,22 @@ vm_cache_remove_consumer(vm_cache_ref *cacheRef, vm_cache *consumer) cache, cacheRef->ref_count, consumer)); for (page = cache->page_list; page != NULL; page = nextPage) { + vm_page *consumerPage; nextPage = page->cache_next; - if (vm_cache_lookup_page(consumerRef, - (off_t)page->cache_offset << PAGE_SHIFT) == NULL) { - // the page already is not yet in the consumer cache - move it upwards + consumerPage = vm_cache_lookup_page(consumerRef, + (off_t)page->cache_offset << PAGE_SHIFT); + if (consumerPage == NULL) { + // the page already is not yet in the consumer cache - move + // it upwards vm_cache_remove_page(cacheRef, page); vm_cache_insert_page(consumerRef, page, (off_t)page->cache_offset << PAGE_SHIFT); - } else if (page->mappings != 0 || page->wired_count != 0) - panic("page %p has still mappings!", page); + } else if (consumerPage->state != PAGE_STATE_BUSY + && (page->mappings != 0 || page->wired_count != 0)) { + panic("page %p has still mappings (consumer cache %p)!", + page, consumerRef); + } } newSource = cache->source;