diff --git a/src/kernel/core/vm/vm_cache.c b/src/kernel/core/vm/vm_cache.c index e23dc9337a..4883510583 100755 --- a/src/kernel/core/vm/vm_cache.c +++ b/src/kernel/core/vm/vm_cache.c @@ -289,6 +289,11 @@ vm_cache_remove_page(vm_cache_ref *cache_ref, vm_page *page) } +/** This function updates the size field of the vm_cache structure. + * If needed, it will free up all pages that don't belong to the cache anymore. + * The vm_cache_ref lock must be held when you call it. + */ + status_t vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize) { @@ -299,8 +304,6 @@ vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize) if (!cache->temporary) return B_NOT_ALLOWED; - mutex_lock(&cacheRef->lock); - oldSize = cache->virtual_size; if (newSize < oldSize) { // we need to remove all pages in the cache outside of the new virtual size @@ -318,8 +321,6 @@ vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize) } cache->virtual_size = newSize; - mutex_unlock(&cacheRef->lock); - vm_increase_max_commit(oldSize - newSize); return B_OK;