Author: cgutman
Date: Wed Dec  7 09:49:49 2011
New Revision: 54605

URL: http://svn.reactos.org/svn/reactos?rev=54605&view=rev
Log:
[NTOSKRNL]
- Optimize the LRU segment selection a bit

Modified:
    trunk/reactos/ntoskrnl/cc/view.c

Modified: trunk/reactos/ntoskrnl/cc/view.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=54605&r1=54604&r2=54605&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Wed Dec  7 09:49:49 2011
@@ -430,8 +430,6 @@
       InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
       DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
     }
-  RemoveEntryList(&CacheSeg->CacheSegmentLRUListEntry);
-  InsertTailList(&CacheSegmentLRUListHead, 
&CacheSeg->CacheSegmentLRUListEntry);
 
   if (Mapped)
   {
@@ -517,6 +515,13 @@
      KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
   }
 
+  KeAcquireGuardedMutex(&ViewLock);
+
+  /* Move to the tail of the LRU list */
+  RemoveEntryList(&CacheSeg->CacheSegmentLRUListEntry);
+  InsertTailList(&CacheSegmentLRUListHead, 
&CacheSeg->CacheSegmentLRUListEntry);
+
+  KeReleaseGuardedMutex(&ViewLock);
 
   CacheSeg->Dirty = TRUE;
   ExReleasePushLock(&CacheSeg->Lock);
@@ -770,6 +775,14 @@
       current = CcRosLookupCacheSegment(Bcb, CurrentOffset);
       if (current != NULL)
        {
+         KeAcquireGuardedMutex(&ViewLock);
+
+         /* Move to tail of LRU list */
+         RemoveEntryList(&current->CacheSegmentLRUListEntry);
+         InsertTailList(&CacheSegmentLRUListHead, 
&current->CacheSegmentLRUListEntry);
+
+         KeReleaseGuardedMutex(&ViewLock);
+
          CacheSegList[i] = current;
        }
       else
@@ -829,6 +842,15 @@
        return Status;
       }
    }
+
+   KeAcquireGuardedMutex(&ViewLock);
+
+   /* Move to the tail of the LRU list */
+   RemoveEntryList(&current->CacheSegmentLRUListEntry);
+   InsertTailList(&CacheSegmentLRUListHead, 
&current->CacheSegmentLRUListEntry);
+
+   KeReleaseGuardedMutex(&ViewLock);
+
    /*
     * Return information about the segment to the caller.
     */


Reply via email to