From bd0bff449fc5d807afe3531aa6fac39a49b3b898 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 7 Jan 2010 15:36:18 +0000 Subject: [PATCH] Changed sAreaCacheLock from mutex to rw_lock. This reduces the lock's contention about two orders of magnitude. Most of it seems to be taken over by other locks, though. Yields only small improvements for the -j8 Haiku image build. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34937 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index bad8ab99b9..642fb0b597 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -104,7 +104,7 @@ public: static mutex sMappingLock = MUTEX_INITIALIZER("page mappings"); -static mutex sAreaCacheLock = MUTEX_INITIALIZER("area->cache"); +static rw_lock sAreaCacheLock = RW_LOCK_INITIALIZER("area->cache"); static off_t sAvailableMemory; static off_t sNeededMemory; @@ -1413,22 +1413,22 @@ vm_map_file(team_id aid, const char* name, void** address, uint32 addressSpec, VMCache* vm_area_get_locked_cache(VMArea* area) { - mutex_lock(&sAreaCacheLock); + rw_lock_read_lock(&sAreaCacheLock); while (true) { VMCache* cache = area->cache; - if (!cache->SwitchLock(&sAreaCacheLock)) { + if (!cache->SwitchFromReadLock(&sAreaCacheLock)) { // cache has been deleted - mutex_lock(&sAreaCacheLock); + rw_lock_read_lock(&sAreaCacheLock); continue; } - mutex_lock(&sAreaCacheLock); + rw_lock_read_lock(&sAreaCacheLock); if (cache == area->cache) { cache->AcquireRefLocked(); - mutex_unlock(&sAreaCacheLock); + rw_lock_read_unlock(&sAreaCacheLock); return cache; } @@ -1665,9 +1665,9 @@ vm_copy_on_write_area(VMCache* lowerCache) upperCache->virtual_end = lowerCache->virtual_end; // transfer the lower cache areas to the upper cache - mutex_lock(&sAreaCacheLock); + rw_lock_write_lock(&sAreaCacheLock); upperCache->TransferAreas(lowerCache); - mutex_unlock(&sAreaCacheLock); + rw_lock_write_unlock(&sAreaCacheLock); lowerCache->AddConsumer(upperCache);