Commit in reactos/ntoskrnl/mm on MAIN
freelist.c+43-41.75 -> 1.76
- Update the page counters in MmGetContinuousPages.  
- Add a flag to PHYSICAL_PAGE, to detect if a free page is on the zeroed or on the unzeroed list.

reactos/ntoskrnl/mm
freelist.c 1.75 -> 1.76
diff -u -r1.75 -r1.76
--- freelist.c	20 Apr 2004 18:59:00 -0000	1.75
+++ freelist.c	31 Jul 2004 09:43:54 -0000	1.76
@@ -30,10 +30,9 @@
    {
       struct
       {
-ULONG Type:
-         2;
-ULONG Consumer:
-         3;
+        ULONG Type: 2;
+        ULONG Consumer: 3;
+	ULONG Zero: 1;
       }
       Flags;
       ULONG AllFlags;
@@ -251,6 +250,12 @@
    for (i = start; i < (start + length); i++)
    {
       RemoveEntryList(&MmPageArray[i].ListEntry);
+      if (MmPageArray[i].Flags.Zero == 0)
+      {
+         UnzeroedPageCount--;
+      }
+      MmStats.NrFreePages--;
+      MmStats.NrSystemPages++;
       MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_USED;
       MmPageArray[i].Flags.Consumer = MC_NPPOOL;
       MmPageArray[i].ReferenceCount = 1;
@@ -261,6 +266,20 @@
                      &MmPageArray[i].ListEntry);
    }
    KeReleaseSpinLock(&PageListLock, oldIrql);
+   for (i = start; i < (start + length); i++)
+   {
+      if (MmPageArray[i].Flags.Zero == 0)
+      {
+         PHYSICAL_ADDRESS Page;
+	 Page.QuadPart = i * PAGE_SIZE;
+	 MiZeroPage(Page);
+      }
+      else
+      {
+      	 MmPageArray[i].Flags.Zero = 0;
+      }
+      		
+   }
 #if defined(__GNUC__)
 
    return((PHYSICAL_ADDRESS)((LONGLONG)start * PAGE_SIZE));
@@ -295,9 +314,11 @@
       if (MmPageArray[i].Flags.Type == 0)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+	 MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].ReferenceCount = 0;
          InsertTailList(&FreeUnzeroedPageListHead,
                         &MmPageArray[i].ListEntry);
+	 MmStats.NrFreePages++;
          UnzeroedPageCount++;
       }
    }
@@ -323,6 +344,9 @@
       if (MmPageArray[i].Flags.Type == MM_PHYSICAL_PAGE_FREE)
       {
          RemoveEntryList(&MmPageArray[i].ListEntry);
+	 UnzeroedPageCount--;
+	 MmStats.NrFreePages--;
+
       }
 
       if (MmPageArray[i].Flags.Type != MM_PHYSICAL_PAGE_BIOS)
@@ -332,6 +356,7 @@
          MmPageArray[i].ReferenceCount = 1;
          InsertTailList(&BiosPageListHead,
                         &MmPageArray[i].ListEntry);
+         MmStats.NrSystemPages++;
       }
    }
 }
@@ -455,6 +480,7 @@
     */
    MmPageArray[0].Flags.Type = MM_PHYSICAL_PAGE_BIOS;
    MmPageArray[0].Flags.Consumer = MC_NPPOOL;
+   MmPageArray[0].Flags.Zero = 0;
    MmPageArray[0].ReferenceCount = 0;
    InsertTailList(&BiosPageListHead,
                   &MmPageArray[0].ListEntry);
@@ -464,6 +490,7 @@
     */
    MmPageArray[1].Flags.Type = MM_PHYSICAL_PAGE_BIOS;
    MmPageArray[1].Flags.Consumer = MC_NPPOOL;
+   MmPageArray[1].Flags.Zero = 0;
    MmPageArray[1].ReferenceCount = 0;
    InsertTailList(&BiosPageListHead,
                   &MmPageArray[1].ListEntry);
@@ -475,6 +502,7 @@
       for (; i<((ULONG)FirstPhysKernelAddress/PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+	 MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].ReferenceCount = 0;
          InsertTailList(&FreeUnzeroedPageListHead,
                         &MmPageArray[i].ListEntry);
@@ -485,6 +513,7 @@
       for (; i<((ULONG)LastPhysKernelAddress / PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_USED;
+         MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].Flags.Consumer = MC_NPPOOL;
          MmPageArray[i].ReferenceCount = 1;
          MmPageArray[i].MapCount = 1;
@@ -495,6 +524,7 @@
       for (; i<(0xa0000/PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+	 MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].ReferenceCount = 0;
          InsertTailList(&FreeUnzeroedPageListHead,
                         &MmPageArray[i].ListEntry);
@@ -504,6 +534,7 @@
       for (; i<(0x100000 / PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_BIOS;
+         MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].Flags.Consumer = MC_NPPOOL;
          MmPageArray[i].ReferenceCount = 1;
          InsertTailList(&BiosPageListHead,
@@ -516,6 +547,7 @@
       for (; i<(0xa0000 / PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+	 MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].ReferenceCount = 0;
          InsertTailList(&FreeUnzeroedPageListHead,
                         &MmPageArray[i].ListEntry);
@@ -525,6 +557,7 @@
       for (; i<(0x100000 / PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_BIOS;
+         MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].Flags.Consumer = MC_NPPOOL;
          MmPageArray[i].ReferenceCount = 1;
          InsertTailList(&BiosPageListHead,
@@ -534,6 +567,7 @@
       for (; i<((ULONG)FirstPhysKernelAddress/PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+	 MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].ReferenceCount = 0;
          InsertTailList(&FreeUnzeroedPageListHead,
                         &MmPageArray[i].ListEntry);
@@ -544,6 +578,7 @@
       for (; i<((ULONG)LastPhysKernelAddress/PAGE_SIZE); i++)
       {
          MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_USED;
+         MmPageArray[i].Flags.Zero = 0;
          MmPageArray[i].Flags.Consumer = MC_NPPOOL;
          MmPageArray[i].ReferenceCount = 1;
          MmPageArray[i].MapCount = 1;
@@ -556,6 +591,7 @@
    for (; i<MemorySizeInPages; i++)
    {
       MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+      MmPageArray[i].Flags.Zero = 0;
       MmPageArray[i].ReferenceCount = 0;
       InsertTailList(&FreeUnzeroedPageListHead,
                      &MmPageArray[i].ListEntry);
@@ -819,6 +855,7 @@
          KEBUGCHECK(0);
       }
       MmPageArray[Start].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+      MmPageArray[Start].Flags.Zero = 0;
       InsertTailList(&FreeUnzeroedPageListHead,
                      &MmPageArray[Start].ListEntry);
       UnzeroedPageCount++;
@@ -966,6 +1003,7 @@
       KEBUGCHECK(0);
    }
    PageDescriptor->Flags.Type = MM_PHYSICAL_PAGE_USED;
+   PageDescriptor->Flags.Zero = 0;
    PageDescriptor->Flags.Consumer = Consumer;
    PageDescriptor->ReferenceCount = 1;
    PageDescriptor->LockCount = 0;
@@ -1057,6 +1095,7 @@
             DbgPrint("Mapped page on freelist.\n");
             KEBUGCHECK(0);
          }
+	 PageDescriptor->Flags.Zero = 1;
          PageDescriptor->Flags.Type = MM_PHYSICAL_PAGE_FREE;
          InsertHeadList(&FreeZeroedPageListHead, ListEntry);
       }
CVSspam 0.2.8