Author: arty
Date: Fri Feb 24 11:33:23 2012
New Revision: 55839

URL: http://svn.reactos.org/svn/reactos?rev=55839&view=rev
Log:
[NEWCC]
Integrate september's speed improvements, which now work.
Remove the flush hack when unpinning cache segments.

Modified:
    trunk/reactos/ntoskrnl/cache/pinsup.c
    trunk/reactos/ntoskrnl/cache/section/data.c
    trunk/reactos/ntoskrnl/cache/section/fault.c
    trunk/reactos/ntoskrnl/cache/section/swapout.c

Modified: trunk/reactos/ntoskrnl/cache/pinsup.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/pinsup.c?rev=55839&r1=55838&r2=55839&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cache/pinsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cache/pinsup.c [iso-8859-1] Fri Feb 24 11:33:23 2012
@@ -130,6 +130,14 @@
        
        DPRINT("Firing work item for %x\n", Bcb->BaseAddress);
 
+    if (Dirty) {
+        CcpUnlock();
+        Bcb->RefCount++;
+        MiFlushMappedSection(ToUnmap, &BaseOffset, &MappedSize, Dirty);
+        Bcb->RefCount--;
+        CcpLock();
+    }
+
        if (Immediate)
        {
                PROS_SECTION_OBJECT ToDeref = Bcb->SectionObject;
@@ -143,8 +151,6 @@
                RemoveEntryList(&Bcb->ThisFileList);
 
                CcpUnlock();
-               if (Dirty)
-                       MiFlushMappedSection(ToUnmap, &BaseOffset, &MappedSize, 
Dirty);
                MmUnmapCacheViewInSystemSpace(ToUnmap);
                ObDereferenceObject(ToDeref);
                CcpLock();
@@ -763,7 +769,6 @@
     CcpUnlock();
 
        if (!Released) {
-               MiFlushMappedSection(RealBcb->BaseAddress, 
&RealBcb->FileOffset, &RealBcb->Map->FileSizes.FileSize, RealBcb->Dirty);
                CcpLock();
                CcpUnpinData(RealBcb, TRUE);
                CcpUnlock();

Modified: trunk/reactos/ntoskrnl/cache/section/data.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/data.c?rev=55839&r1=55838&r2=55839&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] Fri Feb 24 
11:33:23 2012
@@ -259,6 +259,7 @@
                        if (NT_SUCCESS(Status)) {
                                MmLockAddressSpace(AddressSpace);
                                MmSetCleanAllRmaps(Page);
+                               
MmSetPageProtect(MmGetAddressSpaceOwner(AddressSpace), (PVOID)PageAddress, 
PAGE_READONLY);
                                MmLockSectionSegment(Segment);
                                Entry = MmGetPageEntrySectionSegment(Segment, 
&FileOffset);
                                if (Entry && !IS_SWAP_FROM_SSE(Entry) && 
PFN_FROM_SSE(Entry) == Page)
@@ -663,6 +664,11 @@
 
    Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
 
+   if (Page != 0 && PFN_FROM_SSE(Entry) == Page && Dirty)
+   {
+          DPRINT("Freeing section page %x:%x -> %x\n", Segment, 
Offset.LowPart, Entry);
+          MmSetPageEntrySectionSegment(Segment, &Offset, DIRTY_SSE(Entry));
+   }
    if (Page)
    {
           DPRINT("Removing page %x:%x -> %x\n", Segment, Offset.LowPart, 
Entry);
@@ -671,12 +677,7 @@
           MmDeleteVirtualMapping(Process, Address, FALSE, NULL, NULL);
           MmReleasePageMemoryConsumer(MC_CACHE, Page);
    }
-   if (Page != 0 && PFN_FROM_SSE(Entry) == Page && Dirty)
-   {
-          DPRINT("Freeing section page %x:%x -> %x\n", Segment, 
Offset.LowPart, Entry);
-          MmSetPageEntrySectionSegment(Segment, &Offset, DIRTY_SSE(Entry));
-   }
-   else if (SwapEntry != 0)
+   if (SwapEntry != 0)
    {
       MmFreeSwapPage(SwapEntry);
    }

Modified: trunk/reactos/ntoskrnl/cache/section/fault.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/fault.c?rev=55839&r1=55838&r2=55839&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] Fri Feb 24 
11:33:23 2012
@@ -296,6 +296,7 @@
                MmSetPageEntrySectionSegment(Segment, &Offset, 
DIRTY_SSE(Entry));
            }
            MmSetPageProtect(Process, PAddress, PAGE_READWRITE);
+           MmSetDirtyPage(Process, PAddress);
            MmUnlockSectionSegment(Segment);
            DPRINT("Done\n");
            return STATUS_SUCCESS;

Modified: trunk/reactos/ntoskrnl/cache/section/swapout.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/swapout.c?rev=55839&r1=55838&r2=55839&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] Fri Feb 24 
11:33:23 2012
@@ -184,11 +184,12 @@
 (PMMSUPPORT AddressSpace,
  MEMORY_AREA* MemoryArea,
  PVOID Address,
+ BOOLEAN Dirty,
  PMM_REQUIRED_RESOURCES Required)
 {
        NTSTATUS Status = STATUS_SUCCESS;
        ULONG Entry;
-       BOOLEAN Dirty = FALSE;
+    PFN_NUMBER OurPage;
        PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
        LARGE_INTEGER TotalOffset;
        PMM_SECTION_SEGMENT Segment;
@@ -202,24 +203,16 @@
        MmLockSectionSegment(Segment);
        ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
 
-       Dirty = MmIsDirtyPageRmap(Required->Page[0]);
        Entry = MmGetPageEntrySectionSegment(Segment, &TotalOffset);
 
-       if (Dirty)
-       {
-               PFN_NUMBER OurPage;
+       if (Dirty) {
+        DPRINT("Dirty page: %p:%p segment %p offset %08x%08x\n", Process, 
Address, Segment, TotalOffset.HighPart, TotalOffset.LowPart);
                MmSetPageEntrySectionSegment(Segment, &TotalOffset, 
DIRTY_SSE(Entry));
-               MmDeleteRmap(Required->Page[0], Process, Address);
-               MmDeleteVirtualMapping(Process, Address, FALSE, &Dirty, 
&OurPage);
-               ASSERT(OurPage == Required->Page[0]);
-       } else {
-               /* Just unmap if the page wasn't dirty */
-               PFN_NUMBER OurPage;
-               MmDeleteRmap(Required->Page[0], Process, Address);
-               MmDeleteVirtualMapping(Process, Address, FALSE, &Dirty, 
&OurPage);
-               DPRINT("OurPage %x ThePage %x\n", OurPage, Required->Page[0]);
-               ASSERT(OurPage == Required->Page[0]);
-       }
+    }
+
+    MmDeleteRmap(Required->Page[0], Process, Address);
+    MmDeleteVirtualMapping(Process, Address, FALSE, NULL, &OurPage);
+    ASSERT(OurPage == Required->Page[0]);
 
        if (NT_SUCCESS(Status)) 
        {
@@ -368,7 +361,7 @@
 
                   DPRINT("%x:%x, page %x %x\n", Process, Address, Page, 
Resources.Page[0]);
                   Status = MmPageOutCacheSection
-                          (AddressSpace, MemoryArea, Address, &Resources);
+                          (AddressSpace, MemoryArea, Address, Dirty, 
&Resources);
                   DPRINT("%x\n", Status);
                   
                   ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
@@ -398,7 +391,6 @@
                   MmLockAddressSpace(AddressSpace);
           } 
           while (Status == STATUS_MM_RESTART_OPERATION);
-          Dirty |= Resources.State & 1; // Accumulate dirty
 
           MmUnlockAddressSpace(AddressSpace);
 


Reply via email to