Commit in reactos/ntoskrnl on MAIN
mm/pageop.c+11-31.18 -> 1.19
  /anonmem.c+2-21.24 -> 1.25
  /balance.c+6-51.25 -> 1.26
  /rmap.c+9-371.26 -> 1.27
  /section.c+3-31.145 -> 1.146
include/internal/mm.h+1-11.76 -> 1.77
+32-51
6 modified files
- Made it possible to allocate a pageop only if no other pageop for the given address exist.    
- Try to pageout a page only if no other access to the page exist.  
- Gave a free page only to the next waiting request (in MmReleasePageMemoryConsumer),
  if sufficient free pages are available.

reactos/ntoskrnl/mm
pageop.c 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- pageop.c	12 Oct 2003 17:05:48 -0000	1.18
+++ pageop.c	5 Mar 2004 11:31:59 -0000	1.19
@@ -1,4 +1,4 @@
-/* $Id: pageop.c,v 1.18 2003/10/12 17:05:48 hbirr Exp $
+/* $Id: pageop.c,v 1.19 2004/03/05 11:31:59 hbirr Exp $
  *
  * COPYRIGHT:    See COPYING in the top level directory
  * PROJECT:      ReactOS kernel
@@ -134,7 +134,7 @@
 
 PMM_PAGEOP
 MmGetPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
-	    PMM_SECTION_SEGMENT Segment, ULONG Offset, ULONG OpType)
+	    PMM_SECTION_SEGMENT Segment, ULONG Offset, ULONG OpType, BOOL First)
      /*
       * FUNCTION: Get a page operation descriptor corresponding to
       * the memory area and either the segment, offset pair or the
@@ -191,7 +191,14 @@
    */
   if (PageOp != NULL)
     {
-      PageOp->ReferenceCount++;
+      if (First)
+        {
+	  PageOp = NULL;
+	}
+      else
+        {
+          PageOp->ReferenceCount++;
+	}
       KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
       return(PageOp);
     }
@@ -203,6 +210,7 @@
   if (PageOp == NULL)
     {
       KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
+      KEBUGCHECK(0);
       return(NULL);
     }
   

reactos/ntoskrnl/mm
anonmem.c 1.24 -> 1.25
diff -u -r1.24 -r1.25
--- anonmem.c	31 Dec 2003 05:33:03 -0000	1.24
+++ anonmem.c	5 Mar 2004 11:31:59 -0000	1.25
@@ -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: anonmem.c,v 1.24 2003/12/31 05:33:03 jfilby Exp $
+/* $Id: anonmem.c,v 1.25 2004/03/05 11:31:59 hbirr Exp $
  *
  * PROJECT:     ReactOS kernel
  * FILE:        ntoskrnl/mm/anonmem.c
@@ -287,7 +287,7 @@
     */
    PageOp = MmGetPageOp(MemoryArea, (ULONG)MemoryArea->Process->UniqueProcessId, 
 			(PVOID)PAGE_ROUND_DOWN(Address), NULL, 0,
-			MM_PAGEOP_PAGEIN);
+			MM_PAGEOP_PAGEIN, FALSE);
    if (PageOp == NULL)
      {
        DPRINT1("MmGetPageOp failed");

reactos/ntoskrnl/mm
balance.c 1.25 -> 1.26
diff -u -r1.25 -r1.26
--- balance.c	30 Dec 2003 18:52:05 -0000	1.25
+++ balance.c	5 Mar 2004 11:31:59 -0000	1.26
@@ -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: balance.c,v 1.25 2003/12/30 18:52:05 fireball Exp $
+/* $Id: balance.c,v 1.26 2004/03/05 11:31:59 hbirr Exp $
  *
  * PROJECT:     ReactOS kernel 
  * FILE:        ntoskrnl/mm/balance.c
@@ -111,6 +111,7 @@
   PMM_ALLOCATION_REQUEST Request;
   PLIST_ENTRY Entry;
   KIRQL oldIrql;
+  ULONG OldAvailable;
 
 #if defined(__GNUC__)
   if (Page.QuadPart == 0LL)
@@ -126,8 +127,8 @@
   if (MmGetReferenceCountPage(Page) == 1)
     {
       InterlockedDecrement((LONG *)&MiMemoryConsumers[Consumer].PagesUsed);
-      InterlockedIncrement((LONG *)&MiNrAvailablePages);
-      if (IsListEmpty(&AllocationListHead))
+      OldAvailable = InterlockedIncrement((LONG *)&MiNrAvailablePages);
+      if (IsListEmpty(&AllocationListHead) || OldAvailable + 1 < MiMinimumAvailablePages)
 	{
 	  KeReleaseSpinLock(&AllocationListLock, oldIrql);
 	  MmDereferencePage(Page);
@@ -349,7 +350,7 @@
         {
 	  /* MiBalancerEvent */
 	  CHECKPOINT;
-	  while (MiNrAvailablePages < MiMinimumAvailablePages)
+	  while (MiNrAvailablePages < MiMinimumAvailablePages + 5)
 	    {
 	      for (i = 0; i < MC_MAXIMUM; i++)
 	        {
@@ -370,7 +371,7 @@
       else if (Status == STATUS_SUCCESS + 1)
         {
 	  /* MiBalancerTimer */
-	  ShouldRun = MiNrAvailablePages < MiMinimumAvailablePages ? TRUE : FALSE;
+	  ShouldRun = MiNrAvailablePages < MiMinimumAvailablePages + 5 ? TRUE : FALSE;
 	  for (i = 0; i < MC_MAXIMUM; i++)
 	    {
               if (MiMemoryConsumers[i].Trim != NULL)

reactos/ntoskrnl/mm
rmap.c 1.26 -> 1.27
diff -u -r1.26 -r1.27
--- rmap.c	30 Dec 2003 18:52:05 -0000	1.26
+++ rmap.c	5 Mar 2004 11:31:59 -0000	1.27
@@ -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.26 2003/12/30 18:52:05 fireball Exp $
+/* $Id: rmap.c,v 1.27 2004/03/05 11:31:59 hbirr Exp $
  *
  * COPYRIGHT:   See COPYING in the top directory
  * PROJECT:     ReactOS kernel 
@@ -140,24 +140,11 @@
        */
       PageOp = MmGetPageOp(MemoryArea, 0, 0, 
 			   MemoryArea->Data.SectionData.Segment, 
-			   Offset, MM_PAGEOP_PAGEOUT);
-      if (PageOp == NULL)
-	{
-	  DPRINT1("MmGetPageOp failed\n");
-	  KEBUGCHECK(0);
-	}
+			   Offset, MM_PAGEOP_PAGEOUT, TRUE);
 
-
-      if (PageOp->Thread != PsGetCurrentThread())
+      if (PageOp == NULL)
 	{
-	  MmUnlockAddressSpace(AddressSpace);
-          Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
-				         0,
-				         KernelMode,
-				         FALSE,
-				         NULL);
-          KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-	  MmReleasePageOp(PageOp);
+          MmUnlockAddressSpace(AddressSpace);
 	  if (Address < (PVOID)KERNEL_BASE)
 	    {
               ObDereferenceObject(Process);
@@ -179,11 +166,10 @@
   else if (Type == MEMORY_AREA_VIRTUAL_MEMORY)
     {
       PageOp = MmGetPageOp(MemoryArea, Address < (PVOID)KERNEL_BASE ? Process->UniqueProcessId : 0,
-			   Address, NULL, 0, MM_PAGEOP_PAGEOUT);
+			   Address, NULL, 0, MM_PAGEOP_PAGEOUT, TRUE);
       
-      if (PageOp->Thread != PsGetCurrentThread())
+      if (PageOp == NULL)
 	{
-	  MmReleasePageOp(PageOp);
 	  MmUnlockAddressSpace(AddressSpace);
 	  if (Address < (PVOID)KERNEL_BASE)
 	    {
@@ -278,16 +264,9 @@
        */
       PageOp = MmGetPageOp(MemoryArea, 0, 0, 
 			   MemoryArea->Data.SectionData.Segment, 
-			   Offset, MM_PAGEOP_PAGEOUT);
+			   Offset, MM_PAGEOP_PAGEOUT, TRUE);
       if (PageOp == NULL)
 	{
-	  DPRINT1("MmGetPageOp failed\n");
-	  KEBUGCHECK(0);
-	}
-
-      if (PageOp->Thread != PsGetCurrentThread())
-	{
-	  MmReleasePageOp(PageOp);
 	  MmUnlockAddressSpace(AddressSpace);
 	  if (Address < (PVOID)KERNEL_BASE)
 	    {
@@ -310,17 +289,10 @@
   else if (Type == MEMORY_AREA_VIRTUAL_MEMORY)
     {
       PageOp = MmGetPageOp(MemoryArea, Address < (PVOID)KERNEL_BASE ? Process->UniqueProcessId : 0,
-			   Address, NULL, 0, MM_PAGEOP_PAGEOUT);
-      if (PageOp->Thread != PsGetCurrentThread())
+			   Address, NULL, 0, MM_PAGEOP_PAGEOUT, TRUE);
+      if (PageOp == NULL)
 	{
 	  MmUnlockAddressSpace(AddressSpace);
-          Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
-				         0,
-				         KernelMode,
-				         FALSE,
-				         NULL);
-          KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
-	  MmReleasePageOp(PageOp);
 	  if (Address < (PVOID)KERNEL_BASE)
 	    {
               ObDereferenceObject(Process);

reactos/ntoskrnl/mm
section.c 1.145 -> 1.146
diff -u -r1.145 -r1.146
--- section.c	4 Mar 2004 00:07:02 -0000	1.145
+++ section.c	5 Mar 2004 11:31:59 -0000	1.146
@@ -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: section.c,v 1.145 2004/03/04 00:07:02 navaraf Exp $
+/* $Id: section.c,v 1.146 2004/03/05 11:31:59 hbirr Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/section.c
@@ -673,7 +673,7 @@
    /*
     * Get or create a page operation descriptor
     */
-   PageOp = MmGetPageOp(MemoryArea, 0, 0, Segment, Offset, MM_PAGEOP_PAGEIN);
+   PageOp = MmGetPageOp(MemoryArea, 0, 0, Segment, Offset, MM_PAGEOP_PAGEIN, FALSE);
    if (PageOp == NULL)
      {
        DPRINT1("MmGetPageOp failed\n");
@@ -1274,7 +1274,7 @@
     * Get or create a pageop
     */
    PageOp = MmGetPageOp(MemoryArea, 0, 0, Segment, Offset,
-			MM_PAGEOP_ACCESSFAULT);
+			MM_PAGEOP_ACCESSFAULT, FALSE);
    if (PageOp == NULL)
      {
        DPRINT1("MmGetPageOp failed\n");

reactos/ntoskrnl/include/internal
mm.h 1.76 -> 1.77
diff -u -r1.76 -r1.77
--- mm.h	15 Feb 2004 19:03:29 -0000	1.76
+++ mm.h	5 Mar 2004 11:31:59 -0000	1.77
@@ -445,7 +445,7 @@
 
 PMM_PAGEOP
 MmGetPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
-	    PMM_SECTION_SEGMENT Segment, ULONG Offset, ULONG OpType);
+	    PMM_SECTION_SEGMENT Segment, ULONG Offset, ULONG OpType, BOOL First);
 PMM_PAGEOP
 MmCheckForPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
 		 PMM_SECTION_SEGMENT Segment, ULONG Offset);
CVSspam 0.2.8