From ddeb7bfaf144f9d2055d249373764a7a1db5a986 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 25 Aug 2008 22:04:17 +0000 Subject: [PATCH] Changes by Zhao Shuai and myself: * The VMAnonymousCache destructor was unreserving too much physical memory. * Addressed TODO in _SwapBlockBuild(): When the swap block couldn't be allocated we wait and loop until it can. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27202 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/VMAnonymousCache.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp index f3e69d9139..302884cc38 100644 --- a/src/system/kernel/vm/VMAnonymousCache.cpp +++ b/src/system/kernel/vm/VMAnonymousCache.cpp @@ -492,7 +492,8 @@ VMAnonymousCache::~VMAnonymousCache() } swap_space_unreserve(fCommittedSwapSize); - vm_unreserve_memory(committed_size); + if (committed_size > fCommittedSwapSize) + vm_unreserve_memory(committed_size - fCommittedSwapSize); } @@ -911,13 +912,16 @@ VMAnonymousCache::_SwapBlockBuild(off_t startPageIndex, swap_hash_key key = { this, pageIndex }; swap_block *swap = sSwapHashTable.Lookup(key); - if (swap == NULL) { + while (swap == NULL) { swap = (swap_block *)object_cache_alloc(sSwapBlockCache, - CACHE_DONT_SLEEP); + CACHE_DONT_SLEEP); if (swap == NULL) { - // TODO: wait until memory can be allocated + // Wait a short time until memory is available again. mutex_unlock(&sSwapHashLock); - return; + snooze(10000); + mutex_lock(&sSwapHashLock); + swap = sSwapHashTable.Lookup(key); + continue; } swap->key.cache = this;