[haiku-commits] r34937 - haiku/trunk/src/system/kernel/vm

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 7 Jan 2010 16:36:18 +0100 (CET)

Author: bonefish
Date: 2010-01-07 16:36:18 +0100 (Thu, 07 Jan 2010)
New Revision: 34937
Changeset: http://dev.haiku-os.org/changeset/34937/haiku

Modified:
   haiku/trunk/src/system/kernel/vm/vm.cpp
Log:
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.


Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
===================================================================
--- haiku/trunk/src/system/kernel/vm/vm.cpp     2010-01-07 15:32:28 UTC (rev 
34936)
+++ haiku/trunk/src/system/kernel/vm/vm.cpp     2010-01-07 15:36:18 UTC (rev 
34937)
@@ -104,7 +104,7 @@
 
 
 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 @@
 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 @@
        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);
 


Other related posts:

  • » [haiku-commits] r34937 - haiku/trunk/src/system/kernel/vm - ingo_weinhold