[ros-diffs] [sir_richard] 48908: [NTOS]: Stop using MiInsertInListTail and MiRemoveHeadList in the deprecated ReactOS page functions. Those two functions do not adequately support the semantis needed for page ...

sir_richard at svn.reactos.org sir_richard at svn.reactos.org
Mon Sep 27 16:00:24 UTC 2010


Author: sir_richard
Date: Mon Sep 27 16:00:24 2010
New Revision: 48908

URL: http://svn.reactos.org/svn/reactos?rev=48908&view=rev
Log:
[NTOS]: Stop using MiInsertInListTail and MiRemoveHeadList in the deprecated ReactOS page functions. Those two functions do not adequately support the semantis needed for page insertion/removal and should've never been used. MmAllocPage now uses MiRemoveAny/ZeroPage, and MmDereferencePage uses MiInsertPageInFreeList. Should help with some corruptions. More is coming.

Modified:
    trunk/reactos/ntoskrnl/mm/freelist.c

Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev=48908&r1=48907&r2=48908&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] Mon Sep 27 16:00:24 2010
@@ -567,13 +567,11 @@
    Page->u3.e2.ReferenceCount--;
    if (Page->u3.e2.ReferenceCount == 0)
    {
-      MmAvailablePages++;
-      Page->u3.e1.PageLocation = FreePageList;
-      MiInsertInListTail(&MmFreePageListHead, Page);
-      if (MmFreePageListHead.Total > 8 && 0 == KeReadStateEvent(&ZeroPageThreadEvent))
-      {
-         KeSetEvent(&ZeroPageThreadEvent, IO_NO_INCREMENT, FALSE);
-      }
+        /* Mark the page temporarily as valid, we're going to make it free soon */
+        Page->u3.e1.PageLocation = ActiveAndValid;
+
+        /* Bring it back into the free list */
+        MiInsertPageInFreeList(Pfn);
    }
 }
 
@@ -582,44 +580,26 @@
 MmAllocPage(ULONG Type)
 {
    PFN_NUMBER PfnOffset;
-   PPHYSICAL_PAGE PageDescriptor;
-   BOOLEAN NeedClear = FALSE;
-
-   DPRINT("MmAllocPage()\n");
-
-   if (MmZeroedPageListHead.Total == 0)
+   PMMPFN Pfn1;
+   
+   if (Type != MC_SYSTEM)
    {
-       if (MmFreePageListHead.Total == 0)
-       {
-         /* Check if this allocation is for the PFN DB itself */
-         if (MmNumberOfPhysicalPages == 0) 
-         {
-             ASSERT(FALSE);
-         }
-
-         DPRINT1("MmAllocPage(): Out of memory\n");
-         return 0;
-      }
-      PageDescriptor = MiRemoveHeadList(&MmFreePageListHead);
-
-      NeedClear = TRUE;
+       PfnOffset = MiRemoveZeroPage(0);
    }
    else
    {
-      PageDescriptor = MiRemoveHeadList(&MmZeroedPageListHead);
+       PfnOffset = MiRemoveAnyPage(0);
    }
 
-   PageDescriptor->u3.e2.ReferenceCount = 1;
-
-   MmAvailablePages--;
-
-   PfnOffset = MiGetPfnEntryIndex(PageDescriptor);
-   if ((NeedClear) && (Type != MC_SYSTEM))
+   if (!PfnOffset)
    {
-      MiZeroPage(PfnOffset);
+       DPRINT1("MmAllocPage(): Out of memory\n");
+       return 0;
    }
-     
-   PageDescriptor->u3.e1.PageLocation = ActiveAndValid;
+
+   Pfn1 = MiGetPfnEntry(PfnOffset);
+   Pfn1->u3.e2.ReferenceCount = 1;
+   Pfn1->u3.e1.PageLocation = ActiveAndValid;
    return PfnOffset;
 }
 




More information about the Ros-diffs mailing list