- Updated the workingset size in the rmap functions.
authorHartmut Birr <osexpert@googlemail.com>
Sat, 2 Oct 2004 10:16:10 +0000 (10:16 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Sat, 2 Oct 2004 10:16:10 +0000 (10:16 +0000)
svn path=/trunk/; revision=11148

reactos/ntoskrnl/mm/rmap.c

index 9c08f10..c4a21df 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: rmap.c,v 1.30 2004/08/15 16:39:08 chorns Exp $
+/* $Id: rmap.c,v 1.31 2004/10/02 10:16:10 hbirr Exp $
  *
  * COPYRIGHT:   See COPYING in the top directory
  * PROJECT:     ReactOS kernel 
@@ -391,6 +391,7 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
 {
    PMM_RMAP_ENTRY current_entry;
    PMM_RMAP_ENTRY new_entry;
+   ULONG PrevSize;
 
    Address = (PVOID)PAGE_ROUND_DOWN(Address);
 
@@ -416,6 +417,18 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
    new_entry->Next = current_entry;
    MmSetRmapListHeadPage(Page, new_entry);
    ExReleaseFastMutex(&RmapListLock);
+   if (Process == NULL)
+   {
+      Process = PsInitialSystemProcess;
+   }
+   if (Process)
+   {
+      PrevSize = InterlockedExchangeAdd(&Process->Vm.WorkingSetSize, PAGE_SIZE);
+      if (PrevSize >= Process->Vm.PeakWorkingSetSize)
+      {
+         Process->Vm.PeakWorkingSetSize = PrevSize + PAGE_SIZE;
+      }
+   }
 }
 
 VOID
@@ -425,6 +438,7 @@ MmDeleteAllRmaps(PFN_TYPE Page, PVOID Context,
 {
    PMM_RMAP_ENTRY current_entry;
    PMM_RMAP_ENTRY previous_entry;
+   PEPROCESS Process;
 
    ExAcquireFastMutex(&RmapListLock);
    current_entry = MmGetRmapListHeadPage(Page);
@@ -443,7 +457,16 @@ MmDeleteAllRmaps(PFN_TYPE Page, PVOID Context,
          DeleteMapping(Context, previous_entry->Process,
                        previous_entry->Address);
       }
+      Process = previous_entry->Process;
       ExFreeToNPagedLookasideList(&RmapLookasideList, previous_entry);
+      if (Process == NULL)
+      {
+         Process = PsInitialSystemProcess;
+      }
+      if (Process)
+      {
+         InterlockedExchangeAdd(&Process->Vm.WorkingSetSize, -PAGE_SIZE);
+      }
    }
    ExReleaseFastMutex(&RmapListLock);
 }
@@ -472,6 +495,14 @@ MmDeleteRmap(PFN_TYPE Page, PEPROCESS Process,
          }
          ExReleaseFastMutex(&RmapListLock);
          ExFreeToNPagedLookasideList(&RmapLookasideList, current_entry);
+        if (Process == NULL)
+        {
+           Process = PsInitialSystemProcess;
+        }
+        if (Process)
+        {
+            InterlockedExchangeAdd(&Process->Vm.WorkingSetSize, -PAGE_SIZE);
+        }
          return;
       }
       previous_entry = current_entry;