Author: cgutman
Date: Wed Nov 30 21:58:46 2011
New Revision: 54551
URL:
http://svn.reactos.org/svn/reactos?rev=54551&view=rev
Log:
[NTOSKRNL]
- Only flush pages if we can't satisfy Mm's target without using dirty pages
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=545…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Wed Nov 30 21:58:46 2011
@@ -304,18 +304,15 @@
LIST_ENTRY FreeList;
PFN_NUMBER Page;
ULONG i;
+ BOOLEAN FlushedPages = FALSE;
DPRINT("CcRosTrimCache(Target %d)\n", Target);
InitializeListHead(&FreeList);
- /* Flush dirty pages to disk */
- CcRosFlushDirtyPages(Target, NrFreed);
-
- if ((*NrFreed) != 0) DPRINT1("Flushed %d dirty cache pages to disk\n",
(*NrFreed));
-
*NrFreed = 0;
+retry:
KeAcquireGuardedMutex(&ViewLock);
current_entry = CacheSegmentLRUListHead.Flink;
@@ -375,6 +372,25 @@
}
KeReleaseGuardedMutex(&ViewLock);
+
+ /* Try flushing pages if we haven't met our target */
+ if (Target > 0 && !FlushedPages)
+ {
+ /* Flush dirty pages to disk */
+ CcRosFlushDirtyPages(Target, &PagesFreed);
+ FlushedPages = TRUE;
+
+ /* We can only swap as many pages as we flushed */
+ if (PagesFreed < Target) Target = PagesFreed;
+
+ /* Check if we flushed anything */
+ if (PagesFreed != 0)
+ {
+ /* Try again after flushing dirty pages */
+ DPRINT1("Flushed %d dirty cache pages to disk\n", PagesFreed);
+ goto retry;
+ }
+ }
while (!IsListEmpty(&FreeList))
{