From fd772abcb435f8b8149cbd7485b081ec2cda6eef Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 4 Aug 2007 00:36:50 +0000 Subject: [PATCH] Paranoia: vm_cache_insert_page() does now check whether a page for the offset of the page to insert is already in the cache. Revealed the bug fixed with my previous commit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21817 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm_cache.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/system/kernel/vm/vm_cache.cpp b/src/system/kernel/vm/vm_cache.cpp index 1020261797..903e1ba66a 100644 --- a/src/system/kernel/vm/vm_cache.cpp +++ b/src/system/kernel/vm/vm_cache.cpp @@ -294,6 +294,18 @@ vm_cache_insert_page(vm_cache *cache, vm_page *page, off_t offset) state = disable_interrupts(); acquire_spinlock(&sPageCacheTableLock); +#if KDEBUG + struct page_lookup_key key; + key.offset = (uint32)(offset >> PAGE_SHIFT); + key.cache = cache; + vm_page* otherPage = (vm_page *)hash_lookup(sPageCacheTable, &key); + if (otherPage != NULL) { + panic("vm_cache_insert_page(): there's already page %p with cache " + "offset %lu in cache %p; inserting page %p", otherPage, + page->cache_offset, cache, page); + } +#endif // KDEBUG + hash_insert(sPageCacheTable, page); release_spinlock(&sPageCacheTableLock);